When UIViewControllers are instantiated using - (id)initWithNibName:bundle:, you can pass in a bundle.
Is there a way to for the instantiated view controller to find out what its original bundle was?
I have a container UIViewController and I would like to instantiate its child UIViewController using the same bundle the parent was created with. Aside from saving the bundle as an ivar, is there another way to get this?
ContainerViewController *pvc = [[ContainerViewController alloc]
initWithNibName:nil bundle:[NSBundle mainBundle]];
// inside ContainerViewController:
ChildViewController *cvc = [[ChildViewController alloc]
initWithNibName:nil bundle:parentBundle];
UIViewControllerhas a property namednibBundlewhich contains what you are looking for:UIViewController class reference:
So, you could use: