2012-07-24 65 views
0

我已經開始使用故事板和核心數據的主細節應用程序。 的managerObjContext在masterViewController定義:從splitviewcontroller訪問masterViewController

@interface addMasterViewController : UITableViewController <NameEditorViewControllerDelegate> 
    ... 
    @property (strong, nonatomic) NSManagedObjectContext *mngObjCntxt; 

合成在m.file:

@implementation addMasterViewController 
... 
@synthesize mngObjCntxt=_mngObjCntxt; 

現在我試着去設置mngObjCntxt在應用deligate但沒有sucess。這是我曾嘗試:

#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; 
} 

問題是通過IM之上的粗體expresion到達UINavigationController的,而不是給masterViewContoller,其持有mngObjCntxt說。 所以我落在下面的錯誤: - [UINavigationController setMngObjCntxt:]:無法識別的選擇發送到實例 如何訪問masterViewController frm應用程序的解析? 謝謝! Shimrit。

回答

0

確保您在Interface Builder中設置了主視圖控制器的類。

相關問題