Ch5 Add Button Problem With Xcode 4.5

  • Please log in to reply
No replies to this topic



    New Member

  • Members
  • Pip
  • 5 posts

Posted 28 November 2012 - 01:43 PM

Hello there,

I have updated xcode to v4.5 and I got stuck in chapter 5. So far, I was able to show the ingredients and description for each drink, added the "+" button but I haven't been able to make use of the re-use of the Detail View, as described in the book using "presentModalViewController".

How can I show the view re-used for adding new drinks?
Using the code generated by xcode 4.5 I was able to make use of the MainStoryboard, display the list of drinks and navigate to their description (ingredients and directions). But I haven't been able to show the "DrinkDetail" re-used for adding new drinks :(

The exception I got is as follows:

terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle"

Any help? Here's a snippet of my code:

AddDrinkViewController.h and AddDrinkViewController.m have the same code as described in the book.

- (void)addButtonPressed:(id)sender {
	AddDrinkViewController* addDrinkViewController = [[AddDrinkViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
	[self presentModalViewController:addDrinkViewController animated:YES]; //here's where I got the exception
	[addDrinkViewController release];
- (void)viewDidLoad {
	[super viewDidLoad];
	NSString* path = [[NSBundle mainBundle] pathForResource:@"DrinkDirections" ofType:@"plist"];
	drinks_ = [[NSMutableArray alloc]initWithContentsOfFile:path];
	UIBarButtonItem *addButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addButtonPressed:)] autorelease];
	self.navigationItem.rightBarButtonItem = addButton;

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
	if ([[segue identifier] isEqualToString:@"showDetail"]) {
		NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
		DetailViewController *detailViewController = [segue destinationViewController];
		detailViewController.drink = [self.drinks objectAtIndex:indexPath.row];

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users