【发布时间】:2011-01-26 20:14:54
【问题描述】:
我有一个RootViewController(基于导航的应用程序),它要求模型(brain.h/m)执行和检索一些信息。显然我先实例化了一个模型变量。
这是RootViewController.h接口:
#import <UIKit/UIKit.h>
#import "Brain.h"
@interface RootViewController : UITableViewController
{
Brain *cerebro;
}
@property (nonatomic, retain) Brain *cerebro;
@end
我添加了第二个viewcontroller 来控制当用户点击第一个viewcontroller 的tableview 中的一行时显示的详细视图:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
/*
<#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
*/
如何引用并询问第一个 viewcontroller 已实例化的模型而不在第二个 viewcontroller 中再次实例化它?
【问题讨论】:
标签: ios objective-c cocoa-touch model-view-controller