i am trying to create thumbnail of a image i am importing from photo library or camera using a UIImagePickerController using - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)selectedImage editingInfo:(NSDictionary *)editingInfo when i use the camera the thumbnail of the image clicked is easily created but when the same is done by selecting a image from photo library my app crashes.. When i enabled NSZombie in my app it shows f-[UIImage drawInRect:]: message sent to deallocated instance 0x5abc140 on myThumbnail variable..
What am i possible doing wrong??
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)selectedImage editingInfo:(NSDictionary *)editingInfo
{
[self saveImage:selectedImage];
}
- (void)saveImage:(UIImage *)img
{
myThumbNail = img;
UIGraphicsBeginImageContext(CGSizeMake(60.0,60.0));
[myThumbNail drawInRect:CGRectMake(0.0, 0.0, 60.0, 60.0)];// gets killed here
}
What is image in your saveImage: method? I think it should be img. Hope this helps
- (void)saveImage:(UIImage *)img
{
[img retain];
//alloc your myThumbNail before this
myThumbNail = img;
[img release];
UIGraphicsBeginImageContext(CGSizeMake(60.0,60.0));
[myThumbNail drawInRect:CGRectMake(0.0, 0.0, 60.0, 60.0)];// gets killed here
}