How to Save Image to Sandbox - iPhone SDK

I pulled the image from the UIImagePicker thingy, and I would like to temporarily save it in the sandbox environment, either in the document folder, or in another similar equivalent. However, I do not know how to do this, please, can someone help me? Thanks

Image is currently UIImage

0
source share
2 answers

Saving image:

-(void)saveImage:(UIImage*)image{ NSString *imagePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/someImageName.png"]; [UIImagePNGRepresentation(image) writeToFile:imagePath atomically:YES]; } 

Image upload

 -(UIImage)loadImage{ NSString *imagePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/someImageName.png"]; UIImage *image = [UIImage imageWithContentsOfFile:imagePath]; } 
+12
source
 -(void)SaveImage { NSData *data; NSArray *paths; NSString *documentsDirectory,*imagePath ; UIImage *image=[UIImage imageNamed:@"public.png"]; paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); documentsDirectory = [paths objectAtIndex:0]; imagePath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"public.png"]]; data = UIImagePNGRepresentation(image); [data writeToFile:imagePath atomically:YES]; } 
+1
source

All Articles