tags:

views:

83

answers:

1

Following is a snippet of my code:

in the .h file:

@property (nonatomic, retain) UIImage *photo;
@property (nonatomic, retain) NSData *photoData;

in the .m file:

@synthesize photo;
@synthesize photoData;
...
photo = [info objectForKey:@"UIImagePickerControllerOriginalImage"]; {*}
...

NSLog(@"b1");
self.photoData = UIImagePNGRepresentation(self.photo);
NSLog(@"b2");

Here are the logs that I see in the console:

b1
*** -[UIImage CGImage]: message sent to deallocated instance 0x583b1d0

How can i prevent this "message sent to deallocated instance" problem? I am very new to this, so I'd really appreciate some background into why this is happening? (A pointer to some docs would be great too)

Thanks

UPDATE: * The error occurs here. Thanks to codelark for pointing that out. If this line gets changed to the following, the error will not happen.

photo = [[info objectForKey:@"UIImagePickerControllerOriginalImage"] retain];
A: 

0x583b1d0 is likely the address of object in question (the value of self). You can use NSLog or printf with %p to print it.

PK

Pavan