Skip to content

Instantly share code, notes, and snippets.

@inonb
Created July 22, 2012 08:17
Show Gist options
  • Select an option

  • Save inonb/3158884 to your computer and use it in GitHub Desktop.

Select an option

Save inonb/3158884 to your computer and use it in GitHub Desktop.
[iOS] itemをDetailViewControllerに渡す
DetailViewController.h
@property (strong, nonatomic) NSDictionary *item;
DetailViewController.m
@synthesize item;
MasterViewController.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (!self.detailViewController) {
self.detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
}
NSDictionary *item = [items objectAtIndex:indexPath.row];
self.detailViewController.item = item;
[self.navigationController pushViewController:self.detailViewController animated:YES];
}
DetailViewController.m
- (void)viewDidAppear:(BOOL)animated
{
self.title = [[item objectForKey:@"im:name"] objectForKey:@"label"];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment