Monish Kumar
Monish Kumar

Reputation: 2848

Getting memory leaks when using camera integration code in iphone

I'm doing an application which allows user to take a picture from camera or select picture from library. I'm using the code

- (BOOL)startCameraPickerFromViewController:(UIViewController*)controller usingDelegate:(id<UIImagePickerControllerDelegate>)delegateObject  
{  
  if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
  {
    UIImagePickerController *picker = [[[UIImagePickerController alloc] init]autorelease];
    picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    picker.allowsImageEditing = YES;
    picker.delegate = self;
    [controller presentModalViewController:picker animated:YES];

  }

return YES;  
}  

I'm getting memory leak when I'm running this application. I'm running this application on 3.0.

Guys Please help me.

Upvotes: 0

Views: 645

Answers (1)

user498982
user498982

Reputation:

After [controller presentModalViewController:picker animated:YES]; do [picker release]; and get rid of the autorelease when you init the UIImagePickerController. That may work?

Upvotes: 1

Related Questions