O'Reilly Forums: Ch5 Add Button Problem With Xcode 4.5 - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Ch5 Add Button Problem With Xcode 4.5 Ch5 Add button problem (present modal view) using xcode 4.5

#1 User is offline   AJGM 

  • New Member
  • Pip
  • Group: Members
  • Posts: 5
  • Joined: 20-November 08

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.

MasterViewController.m
- (void)addButtonPressed:(id)sender {
	NSLog(@"addButtonPressed");
	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

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users