0

I'm getting this error when clicking on a button in my app:

2012-06-28 21:43:36.860 AppName[2403:707] *** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named NSLayoutConstraint'
*** First throw call stack:
(0x3568788f 0x37a2e259 0x35687789 0x356877ab 0x333a254d 0x333a26bb 0x333a2423 0x33333001 0x332a13c7 0x3317ec59 0x330f4c17 0x330ff267 0x330ff1d5 0x3319e59b 0x3319d367 0x331f86a7 0x8fb11 0x355e13fd 0x330d6e07 0x3319c5e7 0x355e13fd 0x330d6e07 0x330d6dc3 0x330d6da1 0x330d6b11 0x330d7449 0x330d592b 0x330d5319 0x330bb695 0x330baf3b 0x3727a22b 0x3565b523 0x3565b4c5 0x3565a313 0x355dd4a5 0x355dd36d 0x37279439 0x330e9cd5 0x8f6cb 0x8f628)
terminate called throwing an exception

The error occurs in this piece of code:

-(IBAction) goToAbout {
    About *screen = [[About alloc] initWithNibName:nil bundle:nil];
    screen.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentModalViewController:screen animated:YES];
}

Why? Please help me....

nhahtdh
  • 55,989
  • 15
  • 126
  • 162
tracifycray
  • 1,423
  • 4
  • 18
  • 29
  • Well, the error complains on the simple code: -(IBAction) goToAbout { About *screen = [[ About alloc] initWithNibName:nil bundle:nil]; screen.modalTransitionStyle = UIModalTransitionStyleCoverVertical; [self presentModalViewController:screen animated:YES]; } – tracifycray Jun 28 '12 at 19:47
  • You're init-ing a nib with a `nil` bundle? – Dustin Jun 28 '12 at 19:48
  • Sorry, I'm quite new to this. What should I write instead? – tracifycray Jun 28 '12 at 19:50
  • Do you have a nib that you're loading? Normally you would put the name of your nib – Dustin Jun 28 '12 at 19:50
  • By the way, it works on the simulator, but not on my iPhone... – tracifycray Jun 28 '12 at 19:50
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/13184/discussion-between-david-gabor-and-cake) – tracifycray Jun 28 '12 at 19:51
  • what version of Xcode are you using? read this question:http://stackoverflow.com/questions/11198981/presentviewcontroller-crash – self Jul 04 '12 at 12:33

1 Answers1

0

If you are using IOS 5 on your phone, this will crash because presentModalViewController has been deprecated. Use presentViewController instead since it's the new way they do it. If you want to support all versions of IOS you'll have to use a conditional to test to see if the new function is working function before using the newer function. The same is true for dismissModalViewController.

I hope I pointed you in the right direction.

Robert
  • 112
  • 2
  • 13