Return to Snippet

Revision: 24901
at March 15, 2010 11:53 by rabc


Initial Code
// *.h
NSURLConnection* connection; 
NSMutableData* data; 

=======

// *.m

- (void)viewWillAppear:(BOOL)animated {
	
// request the data
	NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.img] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
	connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
	
}

- (void)connection:(NSURLConnection *)theConnection didReceiveData:(NSData *)incrementalData {
    if (data==nil) {
		data = [[NSMutableData alloc] initWithCapacity:2048];
    }
    [data appendData:incrementalData];
}

- (void)connectionDidFinishLoading:(NSURLConnection*)theConnection {
	
    [connection release];
    connection=nil;

// do the stuff with your downloaded data here

}

Initial URL

                                

Initial Description
It was based in Markjnet example here:
>> http://www.markj.net/iphone-asynchronous-table-image/

Initial Title
Assyncrhonous download

Initial Tags
image, download, iphone

Initial Language
Objective C