I am getting a null result for
AppDelegate.h
@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
AppDelegate.m
    @synthesize managedObjectContext = __managedObjectContext;
    @synthesize managedObjectModel = __managedObjectModel;
    @synthesize persistentStoreCoordinator = __persistentStoreCoordinator;
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
          Person *newPerson = [NSEntityDescription
          insertNewObjectForEntityForName:@"Person"
          inManagedObjectContext:self.managedObjectContext];
          .......
    }
I have one xcdatamodeld file with a entity of Person and a attribute of name. I made a Person.h and .m file from a NSManagedObject.
Why am I getting a null result for my output.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+entityForName: nil is not a legal NSManagedObjectContext parameter searching for entity name 'Person''
                In your viewController.m implementation file, right under this bit of code:
- (void)viewDidLoad
{
add this bit of code:
id delegate = [[UIApplication sharedApplication] delegate];
    self.managedObjectContext = [delegate managedObjectContext];
                        I realized that since I was not adding Core Data when I originally created the project, I was missing some code that is automatically generated when the core data option is ticked. Thus, when I followed some tutorials online, this automatically generated code is assumed. That's where I messed up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With