I have this code right here.
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
self.imageView.image = chosenImage;
NSData* imgData=UIImagePNGRepresentation(chosenImage);
[[NSUserDefaults standardUserDefaults] setObject:imgData forKey:@"image"];
[[NSUserDefaults standardUserDefaults]synchronize];
[picker dismissViewControllerAnimated:YES completion:NULL];
}
and then in another view I have
-(void)showImage{
NSData* image=[[NSUserDefaults standardUserDefaults] objectForKey:@"image"];
UIImage* img=[UIImage imageWithData:image];
//now you can use that img image on any imageview
UIImageView *imageView = [[UIImageView alloc] initWithImage:img];
}
I'm trying nsuserdefaults to load the image in the second view, but no matter what I do it won't show in the UIImageView.
Please don't tell me to not use nsuserdefaults I have to use it