Hello.
Im 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 Ive done so far in the program is what Ive listed below.
I created a navigation-based app, uncommented the viewDidLoad: method and added the following lines to it:
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:
In the corresponding implementation file, I wrote the following code for that method:
And thats it. Thats all Ive done. It ought to work, right? When I run the program and tap on the Add button, it crashes and throws the following exception:
Ive tried to use the debugger to figure out what is wrong and all Ive 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.
Im 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 Im running Mac OS X version 10.6.3.
If anyone could lend me a helping hand here, I would really appreciate it. Thank you.
Im 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 Ive done so far in the program is what Ive listed below.
I created a navigation-based app, uncommented the viewDidLoad: method and added the following lines to it:
Code:
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:
Code:
- (void)addSimpleTest;
In the corresponding implementation file, I wrote the following code for that method:
Code:
- (void)addSimpleTest
{
SimpleTest *simpleTest = [[SimpleTest alloc] initWithNibName:@"SimpleTest.xib" bundle:nil];
[self presentModalViewController:simpleTest animated:YES];
[simpleTest release];
}
And thats it. Thats all Ive done. It ought to work, right? When I run the program and tap on the Add button, it crashes and throws the following exception:
Code:
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)'
Ive tried to use the debugger to figure out what is wrong and all Ive 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.
Im 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 Im running Mac OS X version 10.6.3.
If anyone could lend me a helping hand here, I would really appreciate it. Thank you.