Created
April 12, 2012 15:21
-
-
Save quietcricket/2368138 to your computer and use it in GitHub Desktop.
IOS download image asynchronously and cache it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__block ASIHTTPRequest* req=[[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:url]]; | |
req.cachePolicy=ASIOnlyLoadIfNotCachedCachePolicy; | |
req.downloadCache=[ASIDownloadCache sharedCache]; | |
[req setCompletionBlock:^{ | |
UIImage* img=[UIImage imageWithData:[req responseData]]; | |
}]; | |
[req setFailedBlock:^{ | |
NSLog(@"Download Failed"); | |
}]; | |
[req startAsynchronous]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment