I am trying to save a image by picking it from iphone photo library. But I am not able to save it. My UIImage object suddenly releases. I am getting following error:
* -[UIImage release]: message sent to deallocated instance 0x83fa5b0
Please check my code below:
-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSLog(@"finish picking media");
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
if ([mediaType isEqualToString:@"public.image"]){
UIImage *selectedImage = [info objectForKey:UIImagePickerControllerOriginalImage];
NSLog(@"found an image");
selectedImage=[self scaleAndRotateImage:selectedImage];
NSLog(@"image scaled");
//add image to mainpic
imgvwProfile.image = selectedImage;
NSLog(@"11");
//[ setImage:selectedImage forState:UIControlStateNormal];
self.imgPic=selectedImage;
//self.isMainPicImageModified=YES;
NSLog(@"22");
//[self sendImage:selectedImage];
NSLog(@"selectedimage width:%f ht:%f",selectedImage.size.width,selectedImage.size.height);
[self saveImage:selectedImage withImageName:@"profilePic.png"];
NSLog(@"33");
}
}
The error appears when NSLog(@”11″); has been execute.
Can some one please help me why I am getting this error?
Thanks
Pankaj
Can you change below line and check whether this statement makes problem or not.
Let me know now your app crash in this function or not.