I am using UIImagePickerController to take two photos in my app. I am storing those two images in NSData format in two properties declared in AppDelegate which are declared as below.
@property(nonatomic, retain) NSData *dataCheckFront;
@property(nonatomic, retain) NSData *dataCheckBack;
Images I am storing as below:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
NSLog(@"camera took photo...");
[self cleanUpOverlayAndCameraView];
if (iCheckSide==FRONT) {
NSData *dataImage= [[NSData alloc] initWithData:UIImageJPEGRepresentation([info objectForKey:UIImagePickerControllerOriginalImage], 1.0)];
((AppDelegate*)[[UIApplication sharedApplication] delegate]).dataCheckFront= dataImage;
[dataImage release];
dataImage= nil;
}
else {
NSData *dataImage= [[NSData alloc] initWithData:UIImageJPEGRepresentation([info objectForKey:UIImagePickerControllerOriginalImage], 1.0)];
((AppDelegate*)[[UIApplication sharedApplication] delegate]).dataCheckBack= dataImage;
[dataImage release];
dataImage= nil;
}
}
I need the images up-to some point of time in future and I can not avoid storing it somewhere. After the use I am setting those properties to nil like below:
[((AppDelegate*)[[UIApplication sharedApplication] delegate]) setDataCheckBack:nil];
[((AppDelegate*)[[UIApplication sharedApplication] delegate]) setDataCheckFront:nil];
But, before setting it to nil itself, the app is terminating because of low memory issue.
How to solve this?