Reputation: 99
update
DetailViewController *wordDetail = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
wordDetail.wordWordString = [[NSString alloc] initWithString:[[myArray objectAtIndex:indexPath.row] objectForKey:@"word"]];
wordDetail.wordDefinitionString = [[NSString alloc] initWithString:[[myArray objectAtIndex:indexPath.row] objectForKey:@"definition"]];
wordDetail.title = [[myArray objectAtIndex:indexPath.row] objectForKey:@"name"];
[self performSegueWithIdentifier:@"showDetail" sender:self];
here's my new prepare for segue (did you mean i dont need that anymore if i use the above method, or at all? Im actually now sure if all my identifiers are lining up... what do you think?
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
if ([[showDetail] isEqualToString:@"showDetail"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
NSDate *object = _objects[indexPath.row];
[[segue destinationViewController] setDetailItem:object];
Figure it might help to see my DetailViewController.m too...
-(void)setDetailItem:(id)newDetailItem
{
if (_detailItem != newDetailItem) {
_detailItem = newDetailItem;
// Update the view.
[self configureView];
}
if (self.masterPopoverController != nil) {
[self.masterPopoverController dismissPopoverAnimated:YES];
}
}
-(void)configureView
{
//Update the user interface for the detail item.
if (self.detailItem) {
self.detailDescriptionLabel.text = [self.detailItem description];
}
}
- (void)viewDidLoad
{
wordWordLabel.text = wordWordString;
wordDefinitionLabel.text = wordDefinitionString;
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self configureView];
}
Upvotes: 1
Views: 177
Reputation: 18561
Your first section of code is fine. However it is creating a DetailViewController then pushing it along. This means there never is a Segue so your second code doesn't matter at all. You need to decide which you'd like to use.
[self.navigationController pushViewController:wordDetail animated:YES];
This line pushes a viewController on the stack. OR
[self performSegueWithIdentifier:@"showDetail sender:self];
will use the segue in Storyboards named showDetail. You can't have both, you'll need to choose.
Storyboard Identifier
Upvotes: 1