• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: ‘presentModalViewController:setAnimated:’ is throwing an exception.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ‘presentModalViewController:setAnimated:’ is throwing an exception.


  • Subject: Re: ‘presentModalViewController:setAnimated:’ is throwing an exception.
  • From: Christiaan Hofman <email@hidden>
  • Date: Sun, 13 Jun 2010 10:14:15 +0200

I think the problem is that you should not use the extension in the nibName. Certainly not .xib, the app itself contains .nib's.

Chritiaan

On Jun 13, 2010, at 7:38, Aayush Arya wrote:

Hello.

I’m trying to get the ‘Add’ button on my navigation bar in the RootViewController of my navigation-based iPhone application to bring up a modal view controller. All I’ve done so far in the program is what I’ve listed below.

I created a navigation-based app, uncommented the ‘viewDidLoad:’ method and added the following lines to it:

UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addSimpleTest)];
self.navigationItem.rightBarButtonItem = addButton;
[addButton release];

I then hit ⌘N, chose ‘UIViewController subclass’ as the type of file and enabled “With XIB for user interface”. I named it ‘SimpleTest.m’ and enabled “Also create SimpleTest.h”. Then I went back to ‘RootViewController.h’ and added the following method declaration:

- (void)addSimpleTest;

In the corresponding implementation file, I wrote the following code for that method:

- (void)addSimpleTest
{
SimpleTest *simpleTest = [[SimpleTest alloc] initWithNibName:@"SimpleTest.xib" bundle:nil];
[self presentModalViewController:simpleTest animated:YES];
[simpleTest release];
}

And that’s it. That’s all I’ve done. It ought to work, right? When I run the program and tap on the ‘Add’ button, it crashes and throws the following exception:

2010-06-13 10:51:50.617 Testing[24725:207] *** -[NSKeyedUnarchiver initForReadingWithData:]: data is NULL
2010-06-13 10:51:50.621 Testing[24725:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '(null)'

I’ve tried to use the debugger to figure out what is wrong and all I’ve managed to ascertain is that the crash happens when calling the ‘presentModalViewController:setAnimated:’ method and, for the life of me, I just cannot figure out what is wrong.

I’m using Xcode version 3.2.3 (pre-release) 64-bit. The Xcode IDE version is 1680.0. The iPhone Simulator is at version 4.0 (204) and I’m running Mac OS X version 10.6.3.

If anyone could lend me a helping hand here, I would really appreciate it. Thank you.

--
Aayush Arya | http://aayush.me
Regular Contributor, Macworld
Facebook / Flickr / Twitter: aryayush
Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: ‘presentModalViewController:setAnimated:’ is throwing an exception.
      • From: Aayush Arya <email@hidden>
References: 
 >‘presentModalViewController:setAnimated:’ is throwing an exception. (From: Aayush Arya <email@hidden>)

  • Prev by Date: Re: warning: implicit declaration of function 'mach_reply_port'
  • Next by Date: Re: ‘presentModalViewController:setAnimated:’ is throwing an exception.
  • Previous by thread: ‘presentModalViewController:setAnimated:’ is throwing an exception.
  • Next by thread: Re: ‘presentModalViewController:setAnimated:’ is throwing an exception.
  • Index(es):
    • Date
    • Thread