我已经使用故事板和核心数据启动了主详细信息应用程序。 managerObjContext在masterViewController中定义:
@interface addMasterViewController : UITableViewController <NameEditorViewControllerDelegate>
...
@property (strong, nonatomic) NSManagedObjectContext *mngObjCntxt;
并在m.file中合成:
@implementation addMasterViewController
...
@synthesize mngObjCntxt=_mngObjCntxt;
现在我试图在应用程序中设置mngObjCntxt但没有成功。这就是我的尝试:
#import "addAppDelegate.h"
#import "addMasterViewController.h"
#import "addDetailViewController.h"
@implementation addAppDelegate
@synthesize window = _window;
@synthesize splitViewController=_splitViewController;
@synthesize mngObjCntxt = _mngObjCntxt;
@synthesize mngObjModel = _mngObjModel;
@synthesize persistentStoreCoor = _persistentStoreCoor;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
splitViewController.delegate = (id)navigationController.topViewController;
[[[splitViewController viewControllers] objectAtIndex:0] setMngObjCntxt:[self mngObjCntxt]];
return YES;
}
问题是通过上面的粗体表达到达UINavigationController而不是masterViewContoller,它持有mngObjCntxt。 所以我堕落在以下错误: - [UINavigationController setMngObjCntxt:]:无法识别的选择器发送到实例 如何访问appView的masterViewController? 谢谢! Shimrit。
答案 0 :(得分:0)
确保在Interface Builder中设置了主视图控制器的类。