Created
May 15, 2011 11:07
-
-
Save Pablo-Merino/973051 to your computer and use it in GitHub Desktop.
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
NSString *imageName =[NSString stringWithString:[(Tweet*)[tweets objectAtIndex:indexPath.row] author]]; | |
NSString *userImage =[NSString stringWithString:[(Tweet*)[tweets objectAtIndex:indexPath.row] profileImage]]; | |
NSArray *myArray = [userImage componentsSeparatedByString: @"/"]; | |
NSString *fileName = (NSString*)[myArray lastObject]; | |
NSString *picName =[NSString stringWithFormat:@"%@:%@", imageName, fileName]; | |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); | |
NSString *documentsDirectory = [paths objectAtIndex:0]; | |
NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"/ProfilePictures"]; | |
NSString* path = [dataPath stringByAppendingPathComponent:picName]; | |
UIImage* image = [UIImage imageWithContentsOfFile:path]; | |
if (!image) { | |
UIImage *phoneImage=[UIImage imageWithData:[[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:userImage]]]; | |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); | |
NSString *documentsDirectory = [paths objectAtIndex:0]; | |
NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"/ProfilePictures"]; | |
NSString* path = [dataPath stringByAppendingPathComponent:picName]; | |
NSData* data = UIImagePNGRepresentation(phoneImage); | |
[data writeToFile:path atomically:YES]; | |
} | |
else{ | |
[cell.imageView setImage:image]; | |
} |
md347
commented
May 15, 2011
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment