Skip to content

Instantly share code, notes, and snippets.

@duyhungtnn
Forked from masbog/sampleCache.m
Created March 22, 2013 07:46
Show Gist options
  • Save duyhungtnn/5219625 to your computer and use it in GitHub Desktop.
Save duyhungtnn/5219625 to your computer and use it in GitHub Desktop.
#define TMP NSTemporaryDirectory()
- (NSString*)setFileName:(NSString*)url
{
NSArray *tokenize = [url componentsSeparatedByString: @"/"];
NSString *imageFile = [tokenize objectAtIndex:([tokenize count]-1)];
//NSLog(@"%@",imageFile);
return imageFile;
}
//saving or get from temporary dir on some void
NSString *urlImage = "URL OF IMAGE";
NSString *filename = [self setFileName:urlImage];
NSString *uniquePath = [TMP stringByAppendingPathComponent:filename];
if(![[NSFileManager defaultManager] fileExistsAtPath:uniquePath])
{
ShowNetworkActivityIndicator();
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:urlImage]];
[request setTag:x];
[request setDelegate:self];
[request startAsynchronous];
}else
{
//do somethink if file exist
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment