NSURL *url = [NSURL URLWithString:@\"http://i0.kym-cdn.com/entries/icons/original/000/005/545/OpoQQ.jpg?1302279173\"];
NSData *data = [NSData dataWithContentsOfURL:url]
You can't get progress call backs by using that method.
You need to use an NSURLConnection
and NSURLConnectionDataDelegate
.
The NSURLConnection
then runs asynchronously and will send callbacks to its delegate.
The main ones to look at are...
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response;
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error;
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data;
and
- (void)connectionDidFinishLoading:(NSURLConnection *)connection;
These are all used for getting the connection to do what you're already doing.
EDIT
Actually, see Marc's answer below. It is correct.