ios - Passing managedobjectContext to tabbarcontroller with navigation controllers in modal view -
for small app, have login screen. on auth, tab bar controller 2 views (one navigation controller) presented. following tutorial. uses core data. http://maybelost.com/2011/12/tutorial-storyboard-app-with-core-data/
tutorial calls segue. use presentmodalviewcontroller. works, except wondering how pass managedobjectcontext view inside navigation control inside tab bar controller.
i read passing managedobjectcontext view controllers using storyboards root uitabbarcontroller, comments under second answer not right method.
can tell me correct way it? looking know how reference view inside tabbar controller can set managedobjectcontext view.
thanks
edit in appdelegate.h:
@interface appdelegate : uiresponder <uiapplicationdelegate> @property (readonly, strong, nonatomic) nsmanagedobjectcontext *managedobjectcontext;
my appdelegate.m :
- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { loginviewcontroller *rootview = (loginviewcontroller *)self.window.rootviewcontroller; rootview.managedobjectcontext = self.managedobjectcontext; }
actually tend grab context tabbarcontroller of view in. instance, in viewwillappear view in tab bar create instance of self.tabbarcontroller , set views context context. way can pass context tabbar , each view can reference tabbar's context.
something this.
maintabbar *parenttabbarcontroller = (mytabbar *)self.tabbarcontroller; self.managedobjectcontext = parenttabbarcontroller.managedobjectcontext;
Comments
Post a Comment