I understand that I can't programmatically delete photos from my app . Because Apple writes that we can only add photos
To save a still image to the user’s Saved Photos album, use the UIImageWriteToSavedPhotosAlbum function. To save a movie to the user’s Saved Photos album, use the UISaveVideoAtPathToSavedPhotosAlbum function.
But I find project that have photos in project, so I can delete photos from this app by clicking delete icon (but still it crashes then =) ) project
And now I see only two ways:
So after all my searching I haven't found a solution. Are their some ways to solve my problem?
On Youtube I find next video and I understand that I can save photo to document directory. It was next code in video
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
NSData *data = UIImagePNGRepresentation (image);
NSString *myGrabbedImage = @"myGrabbedImage.png";
NSArray *path = NSSearchPathForDirectoriesInDomainns (NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory = [path objectAtIndex:0];
NSString *fullPathToFile = [documentDirectory stringByAppendingPathComponent:myGrabbedImage];
[data writeToFile:fullPathToFile atomically:YES];
So I understand that is simple to save photo from Photo Library to my array, and then open photos from array. And I will can than simply delete photos by remove them from my array. Ok, but now I have 2 questions:
- How I can distinguish photos that i will save in my array? If I will allocate same photo in Photo Library it will be save some times - it's not good.
- So it will be work only with PNG images?
PS Sorry, if this questions very newbiest, but my brain exploded after allday searching.