I’m still a bit confused on models and saving data, perhaps someone could help me out. I have a page where user can import a photo from there camera roll.As soon as I move to next page its gone again. I can save text data in a NString from text boxes but im unsure how to do this with an image. Image is displayed in UI webview.
xcode 4.3
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
if((UIButton *) sender == choosePhotoBtn) {
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
}
[self presentModalViewController:picker animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissModalViewControllerAnimated:YES];
imageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
First Of all Try to post some code of ur problem. it makes us help u better.
Okay from what i have speculated the problem is that u are loosing the image when u push to the new view . well i had this problem and i solved it using Singleton Class. it sorta create Global elements and u can store values which u prefer to hold. including Images, Class Objects (u name it)
U can hold as much values as u want and u dont even have to store it in ur Library.
Try Reading Singleton Classes On Internet i m sure our good friend Google will certainly help u out
EDITED ——– About SINGLETON
okay since u have read about Singleton. u might have notice why do we use Singleton Classes, The Major purpose of Singleton is to hold global variables, but u know that dont u.!!! so about ur issues, when u pick an image (either from Camera or Photo Galary) it will return to u an Object of UIImage.
u must have a Class of Singleton Some thing Like
And the M file will look something like this
now all u got to do is to call the sharedSingletonController function in the class where want to use the singleton Image variable like and yeah dont forgot to create an Object of Singleton Class
Some thing like that
now u can store ur image in singleton like
Now the image will be saved in ur Singleton object. So when it will not be lost and u can use it anytime u and in any class u like
Cheers
Let ME Know if it Worked
W