I created an iOS project and a managed object model (Model.xcdatamodeld
) with one entity. In application:didFinishLaunchingWithOptions:
I want to test if the managed object model exists, however I am getting nil
. Do I have to do something special to create the managed object context after I create the managed object model?
Any suggestions on what I may be doing wrong?
This is the interface
@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
}
@property (nonatomic, strong, readonly) NSManagedObjectContext *managedObjectContext;
@property (nonatomic, strong, readonly) NSManagedObjectModel *managedObjectModel;
@property (nonatomic, strong, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator;
@end
This is the implementation file
#import "AppDelegate.h"
#import "RootViewController.h"
@implementation AppDelegate
@synthesize window = _window;
@synthesize managedObjectContext = _managedObjectContext;
@synthesize managedObjectModel = _managedObjectModel;
@synthesize persistentStoreCoordinator = _persistentStoreCoordinator;
@synthesize navigationController = _navigationController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if (![self managedObjectContext])
{
NSLog(@"Does not exist");
}
return YES;
}