1. Save Photos
1- (void) Setphoto: (UIImage *) image{2UIImage *image =image;3 45 //0.5 for compression ratio, 1 for uncompressed, highest image quality, 0 for highest compression, lowest image quality6NSData *imagedata = uiimagejpegrepresentation (image,0.5);7NSString *relativepath =@"userphoto.jpg";8NSString *path =[self documentspathforfilename:relativepath];9NSLog (@"Path%@", path);Ten [ImageData Writetofile:path atomically:yes]; One [[Nsuserdefaults standarduserdefaults] Setobject:path Forkey:kuserimagepath]; A [[Nsuserdefaults standarduserdefaults] synchronize]; - } - the-(nsstring*) Documentspathforfilename: (nsstring*) name{ -Nsarray *paths =nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES); -NSString *documentspath = [Paths Objectatindex:0]; - return[Documentspath stringbyappendingpathcomponent:name]; +}
2. Read photos
NSString *imagepath = [[nsuserdefaults standarduserdefaults] objectforkey:kuserimagepath]; if (ImagePath) { = [UIImage imagewithdata:[nsdata datawithcontentsoffile:imagepath]; }
The main idea here is to save the photo to the application file and save the path to Nsuserdefaults
When reading a photo, read the path from Nsuserdefaults and then read the photo.
Source of the method: Http://stackoverflow.com/questions/6648518/save-images-in-nsuserdefaults
Access photos in the app