You will need to use NSURLConnection. It is quite simple, but more active than the NSData method.
First create an NSURLConnection:
NSMutableData *receivedData;
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:imgLink]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection) {
receivedData=[[NSMutableData data] retain];
} else {
}
Now add <NSURLConnectionDelegate> to the header of your class and implement the following methods:
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data;
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error;
- (void)connectionDidFinishLoading:(NSURLConnection *)connection;
, , .
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data;
{
[receivedData appendData:data];
}
. .