to save a picture for example:
1. Save
/**
* Save user Avatar * *
+ (NSString *) Saveuserimage: (UIImage *)
image{nsstring; Gets the document path
Nsarray *document = Nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES);
NSString *path = [document objectatindex:0];
Nsfilemanager *maneger = [Nsfilemanager Defaultmanager];
NSString *documentpath = [path stringbyappendingpathcomponent:@ "Mxuserimagefile"];
if (![ Maneger Fileexistsatpath:documentpath]) {
[Maneger Createdirectoryatpath:documentpath Withintermediatedirectories:yes Attributes:nil Error:nil];
}
url = [documentpath stringbyappendingpathcomponent:@ "Userimage.jpeg"];
NSData *imagedata = uiimagejpegrepresentation (image, 1.0);
[ImageData Writetofile:url Atomically:yes];
return @ "Documents/mxuserimagefile/userimage.jpeg";
}
2. Delete Direct call Remove method (here is simple to write)
[Maneger Removeitematpath:path Error:nil];
3. Using User.avatarurl is Documents/mxuserimagefile/userimage.jpeg
NSString *path = [Nshomedirectory () STRINGBYAPPENDINGPATHCOMPONENT:USER.AVATARURL];
[_headerimage Setimage:[uiimage Imagewithcontentsoffile:path]];
Note: Using the document store does not save an absolute path, because the name applied to the sandbox will change.