Reputation: 145
I'm trying to set a property (NSManagedObject) of a view controller in another storyboard and present it:
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"MySecondStoryboard" bundle:nil];
MyViewController* initialView = [storyboard instantiateInitialViewController];
initialView.entity= self.entity;
initialView.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:initialView animated:YES completion:nil];
But when it gets to
initialView.entity= self.entity;
I get
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationController setEntity:]: unrecognized selector sent to instance
Interestingly,
MyViewController* initialView = [[MyViewController alloc] init];
initialView.entity= self.entity;
works, but I can't load it because it should be instantiated by its storyboard.
Thanks in advance
Upvotes: 1
Views: 314
Reputation: 1453
Make sure that you have connected the MyViewcontroller to the correct storyboard view controller, and the story board is marked as initial. then try casting like
MyViewController* initialView =(MyViewController *) [storyboard instantiateInitialViewController];
Upvotes: 0
Reputation: 6918
First replace:
MyViewController* initialView = [storyboard instantiateInitialViewController];
with:
MyViewController* initialView = [storyboard instantiateViewControllerWithIdentifier:@"ID"];
Last go to your second storyboard and go to your view controller. Set the storyboard ID to "ID".
Upvotes: 2