Note that there are some explanatory texts on larger screens.

plurals
  1. POCore Data error message
    text
    copied!<p>I created a Core Data Entity named: "Athlete".</p> <p>Here is the error that I am getting:</p> <pre><code>Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+entityForName: nil is not a legal NSManagedObjectContext parameter searching for entity name 'Athlete'' </code></pre> <p>This is the line at where it breaks:</p> <pre><code>Athlete *detail = [NSEntityDescription insertNewObjectForEntityForName:@"Athlete" inManagedObjectContext:context]; </code></pre> <p>delegate.h</p> <pre><code>@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext; @property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel; @property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator; </code></pre> <p>delegate.m</p> <pre><code>-(void)createData{ NSManagedObjectContext *context = [self managedObjectContext]; Athlete *detail = [NSEntityDescription insertNewObjectForEntityForName:@"Athlete" inManagedObjectContext:context]; detail.first = @"Joe"; detail.last = @"Pastrami"; detail.phone = @"(123)456-7891"; NSError *error; if(![context save:&amp;error]){ NSLog(@"Error :("); } NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Athlete" inManagedObjectContext:context]; [request setEntity:entity]; NSArray *arr = [context executeFetchRequest:request error:&amp;error]; for (Athlete *ath in arr){ NSLog(@"Name %@", ath.first); } } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [self createData]; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload