I want to open an image from the cameraroll and resize it so the user can get a preview of all the changes he's applying to the image without the image taking up too much memory. After the user finishes doing whatever he has to do with the image I allow the user to save the image. When the image is saved, the full sized image is retrieved from the UIImagePickerOriginalImage key and the changes are applied to the full image as well. But there is one big issue.
I can't seem to be able to store the ImagePickerController's Dictionary for use in the save IBAction.
Here's some code to explain my issue :
This is the part where the image is loaded to imaget (the preview's UIImage)
and where the NSDictionary is being stored in a variable I declared before (NSDictionary *dict; )
Code:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)editInfo
{
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
dict = editInfo;
UIImage *imaget = [dict objectForKey:@"UIImagePickerControllerOriginalImage"];
//image get resized
//image gets loaded into the preview
}
Here everything goes smoothly, the image loads into the preview.
Everything that happens between this action and where the user saves is irrelevant as it all works and used to work before.
But here's where the big problem arrises :
In my Save Action I want to call the Original image again from the "dict" NSDictionary, but this fails miserably eventually crashing the app.
Code:
UIImage *imaget = [dict objectForKey:@"UIImagePickerControllerOriginalImage"];
//perform all changes
//save the image
The issue is in the above code and not in any other as I simplified the app until basically only the above code remained and the problem still persisted.
Can anyone help me? Can this NSDictionary be stored into a variable for later use?