I'm creating a simple interface with NavigationController and BandListViewController(UITableViewController) inside Interface Builder and setting the delegation to AppDelegate properties.
@interface CRUDAppDelegate : NSObject <UIApplicationDelegate> {
UINavigationController *bandNav;
BandListViewController *bandList;
}
and
However, I can't figure out how can I initialize my BandListViewController passing the paramater managedObjectContext without setting it on awakeFromNib. The CRUDAppDelegate already init this controller and set his own nib into the navigationController, but then when I try to make a new BandListViewController in didFinishLaunchingWithOptions with initInManagedObjectContext, the display (TableViewController) remains of the old bandList. (with managedObjectContext = null)
What I've done so far is keeping the bandList managedObjectContext at awakeFromNib as Apple suggests.
- (void)awakeFromNib
{
/*
Typically you should set up the Core Data stack here, usually by passing the managed object context to the first view controller.
self.<#View controller#>.managedObjectContext = self.managedObjectContext;
*/
self.bandList.managedObjectContext = self.managedObjectContext;
}
What I wanted
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.bandList = [[BandListViewController alloc] initInManagedObjectContext:self.managedObjectContext];
// Override point for customization after application launch.
[self.window addSubview:bandNav.view];
[self.window makeKeyAndVisible];
return YES;
}