Posts

Showing posts from June, 2013

Download image from URL.

I'll throw on a few examples using asynchronous requests. 1.  blocks in  NSURLConnection :  - ( void ) NSURLConnectionExample { NSURLRequest * request = [ NSURLRequest requestWithURL :[ NSURL URLWithString :@ "http://www.google.com/images/srpr/logo3w.png" ] cachePolicy : NSURLCacheStorageNotAllowed timeoutInterval : 10.0 ]; [ NSURLConnection sendAsynchronousRequest : request queue :[ NSOperationQueue mainQueue ] completionHandler :^( NSURLResponse * response , NSData * data , NSError * err ){ if (! err && data ) { NSArray * paths = NSSearchPathForDirectoriesInDomains ( NSDocumentDirectory , NSUserDomainMask , YES ); NSString * documents = [ paths objectAtIndex : 0 ]; NSString * finalPath = [ documents stringByAppendingPathComponent :@ "myImageName.png" ]; [ data writeToFile : finalPath atomically : YES ]; } }]; } 2. Grand Central Disp