Can't process UIImage from UIImagePickerController and app crashes..
- by eimaikala
Hello guys,
I am new to iPhone sdk and can't figure out why my application crashes.
In the .h I have:
UIImage *myimage; //so as it can be used as global
-(IBAction) save;
@property (nonatomic, retain) UIImage *myimage;
In the .m I have:
@synthesize myimage;
- (void)viewDidLoad {
self.imgPicker = [[UIImagePickerController alloc] init];
self.imgPicker.allowsImageEditing = YES;
self.imgPicker.delegate = self;
self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
myimage = [[info objectForKey:UIImagePickerControllerOriginalImage]retain];
[picker dismissModalViewControllerAnimated:YES];
}
-(IBAction) process{
myimage=[self process:myimage var2:Val2 var3:Val3 var4:Val4];
UIImageWriteToSavedPhotosAlbum(myimage, nil, nil, nil);
[myimage release];
}
When the button process is clicked, the application crashes and really I
have no idea why this happens.
When i change it to:
-(IBAction) process{
myimage =[UIImage imageNamed:@"im1.jpg"];
myimage=[self process:myimage var2:Val2 var3:Val3 var4:Val4];
UIImageWriteToSavedPhotosAlbum(myimage, nil, nil, nil);
[myimage release];
}
the process button works perfectly...
Any help would be appreciated.
Thanks in advance