Created
April 24, 2012 15:12
-
-
Save masbog/2480460 to your computer and use it in GitHub Desktop.
Save image into temporary directory iOS
This file contains 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
#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