0

I am using ABNewPersonViewController to add new contact to the address book. Every thing is fine if I do not add any photo from photo albums. It crashes if I add any photo and here is the log:-

NSInvalidArgumentException', reason: '*** -[NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: UIImagePickerControllerOriginalImage)

What I am doing wrong, or how I can fix this problem

Thanks

This is the code I use:

 mNewPersonViewController = [[[ABNewPersonViewController alloc]init]autorelease];
 mNewPersonViewController.hidesBottomBarWhenPushed = YES;
 mNewPersonViewController.addressBook = app.addressBook;
 mNewPersonViewController.newPersonViewDelegate = self;

 UINavigationController *presonNavController = [[UINavigationController alloc]initWithRootViewController:mNewPersonViewController];
 self.mPopOverController = [[UIPopoverController alloc]initWithContentViewController:presonNavController ];
 CGRect frame = [sender frame];
 [self.mPopOverController presentPopoverFromRect:frame inView:self.view permittedArrowDirections: UIPopoverArrowDirectionUp animated:YES];
 [presonNavController release];
vikas
  • 827
  • 1
  • 9
  • 19
  • where is the code that adds to the dictionary? – willcodejavaforfood Jul 22 '10 at 13:18
  • It is ABNewPersonViewController class that is doing rest of the task,once popover has come. – vikas Jul 22 '10 at 13:24
  • OK I don't think there will be a bug like that in Apple's code so do you have any code that uses a dictionary or just any code that executes after the ABNewPersonViewController? – willcodejavaforfood Jul 22 '10 at 13:45
  • Thanks for your help.I think that i got the answer. Actually it crashes only in simulator.It is fine on device.if you are using sdk 3.2 beta.but fixes later.Even apple contact application is crashing on simulator while selecting photo. – vikas Jul 22 '10 at 14:26
  • What does your delegate code do? Is there a UIImagePickerController already in the navigation stack? – JBRWilkinson Jul 22 '10 at 14:32
  • No, UIImagePickerController is not on the stack.(I have not used it at all). it crashes only in simulator.It is fine on device.Thanks. – vikas Jul 22 '10 at 14:55

1 Answers1

0

Looks like you are trying to insert a nil value into the dictionary.

willcodejavaforfood
  • 43,223
  • 17
  • 81
  • 111
  • yea,I know as it is shown in log.But how can i fix this problem.since ABNewPersonViewController is address book framework class ,what i can do to fix this. thanks for your help. – vikas Jul 22 '10 at 13:21
  • I have initialize the ABNewPersonViewController and then initialize navigation controller with ABNewPersonViewController and then present the navigation controller inside the popover. – vikas Jul 22 '10 at 13:32