WHAT I AM DOING:
Hi guys, I am currently learning iOS development. I have encountered a problem, which I have solved. However, I don't actually know what happened, that it worked. I am doing a DrinkMixer app from a book called:”Head first Iphone & Ipad development”(2nd edition). The book is written for Xcode 4 and iOS4 Sdk, while I work on Xcode 5 with iOS 7.
GOAL:
I am trying to create a new view which I want to be pushed as a Modal view in order to make the user fill in new drink informations.
CODE BREAKING POINT:
@autoreleasepool
{
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
BREAKING CODE:
-(IBAction)addButtonPressed:(UIBarButtonItem *)sender
{
DummyAddDrink *someDrink = [[DummyAddDrink alloc] initWithNibName:@"DetailViewController" bundle:nil];
[self presentModalViewController:someDrink animated:YES];
}
WORKING CODE:
-(IBAction)addButtonPressed:(UIBarButtonItem *)sender
{
DummyAddDrink *someDrink = [self.storyboard instantiateViewControllerWithIdentifier:@"DetailViewController"];[/u][/b]
[self presentModalViewController:someDrink animated:YES];
}
CODE EXPLANATION: addButtonPressed is connected to a "Bar Button Item" in a "Navigation Bar". When the BBI is clicked it calls aBP. aBP creates a new view by subclassing from a existing controller called "DetailViewController". The DVC has his own .h, .m, VC in IB.
ERROR OUTPUT:
2013-12-18 09:57:02.735 DrinkMixer_Take_2[848:70b] NSBundle </Users/.../Library/Application Support/iPhone Simulator/7.0/Applications/408E0817-824B-40A6- B1B2-34DDC8043712/DrinkMixer_Take_2.app> (loaded)
2013-12-18 09:57:37.105 DrinkMixer_Take_2[848:70b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/.../Library/Application Support/iPhone Simulator/7.0/Applications/408E0817-824B-40A6- B1B2-34DDC8043712/DrinkMixer_Take_2.app> (loaded)' with name 'DetailViewController''
QUESTION:
Why does my program break with :
DummyAddDrink *someDrink = [[DummyAddDrink alloc] initWithNibName:@"DetailViewController" bundle:nil];