// will be " cropped photos " is written to the sandbox
-(void) writeintosandboxwithimage: (UIImage *) image
{
nsarray * paths = nssearchpathfordirectoriesindomains ( NSDocumentDirectory , nsuserdomainmask , YES );
nsstring *path = [[Paths objectatindex : 0 ] stringbyappendingpathcomponent : [ Strong>nsstring stringWithFormat : Span class= "S6" > sandbox_avater ]]; // Save file name
BOOL result = [uiimagepngrepresentation(image) WriteToFile:p ath atomically:YES]; // Save successful will return YES
if (result) {
debuglog(@ "' cropped avatar or initial avatar ' write to sandbox : success ");
} else {
debuglog(@ "' cropped avatar or initial avatar ' write to sandbox : failed ");
}
}
// read from sandbox " original saved photos "
-(UIImage *) Readfromsandboxwithpath: (nsstring *) path
{
// Get the path inside the application sandbox
nsarray *paths = nssearchpathfordirectoriesindomains( /c20>nsdocumentdirectory,nsuserdomainmask, YES );
// Read the file image that exists in the sandbox
nsstring *imgpath = [[Paths objectatindex:0 ] stringbyappendingpathcomponent:p ath];
// because a path is taken to load it into a data Object
nsdata *data = [nsdatadatawithcontentsoffile: Imgpath];
// read the picture directly
UIImage *image = [UIImageimagewithdata:d ata ];
return image;
}
Sandbox read-write