ios - Passing managedObjectContext via presentViewController -


i trying "pass baton" method passing managedobjectcontext (moc) thru multiple views. have passed rootviewcontroller. there move tabbarcontroller via presentviewcontroller. can't seem find way pass moc when tabbarcontroller pushed.

appdelegate.m

uiviewcontroller *navigationcontroller = (uiviewcontroller *)self.window.rootviewcontroller; myviewcontroller *controller = (myviewcontroller *) navigationcontroller; controller.managedobjectcontext = managedobjectstore.mainqueuemanagedobjectcontext; 

the main view controller start screen kick login screen or if logged in, tabbarcontroller. below transition tabbarcontroller within viewdidappear method.

myviewcontroller.m

uistoryboard *storyboard = [uistoryboard storyboardwithname:@"mainstoryboard_iphone" bundle:nil]; uiviewcontroller *maintabvc = [storyboard instantiateviewcontrollerwithidentifier:@"maintabvc"]; [maintabvc setmodalpresentationstyle:uimodalpresentationfullscreen]; [self presentviewcontroller:maintabvc animated:no completion:nil]; 

the tabbarcontroller in storyboard has identifier "maintabvc".

i've tried lines like

mytabbarcontroller.managedobjectcontext = self.managedobjectcontext; 

but error property 'moc' not found on object of type mytabbarcontroller though have property declared in mytabbarcontroller.h

could show me line of code can throw in segue push moc tab bar controller.

btw- i'm utilizing restkit in app if changes way should handling please let me know.

*****solution********

to make things clear other new guys same question. went this:

    uistoryboard *storyboard = [uistoryboard storyboardwithname:@"mainstoryboard_iphone" bundle:nil];     uiviewcontroller *maintabvc = [storyboard instantiateviewcontrollerwithidentifier:@"maintabvc"];     [maintabvc setmodalpresentationstyle:uimodalpresentationfullscreen];     [self presentviewcontroller:maintabvc animated:no completion:nil]; 

to this:

    uistoryboard *storyboard = [uistoryboard storyboardwithname:@"mainstoryboard_iphone" bundle:nil];     mytabbarviewcontroller *maintabvc = [storyboard instantiateviewcontrollerwithidentifier:@"maintabvc"];      maintabvc.managedobjectcontext = self.managedobjectcontext;     [maintabvc setmodalpresentationstyle:uimodalpresentationfullscreen];     [self presentviewcontroller:maintabvc animated:no completion:nil]; 

notice assignment in third line , using mytabbarviewcontroller instead of uiviewcontroller in second line. big again rdelmar!

your code confusing. mytabbarcontroller class? looks maintabvc instance. should use rather class, , should change type when instantiate maintabvc mytabbarcontroller, instead of uitabbarcontroller. don't need storyboard way do, can use self.storyboard.

    mytabbarcontroller *maintabvc = [self.storyboard instantiateviewcontrollerwithidentifier:@"maintabvc"];     maintabvc.managedobjectcontext = self.managedobjectcontext;     [maintabvc setmodalpresentationstyle:uimodalpresentationfullscreen];     [self presentviewcontroller:maintabvc animated:no completion:nil]; 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -