Note that there are some explanatory texts on larger screens.

plurals
  1. POCould not locate NSManagedObjectModel for Entity
    primarykey
    data
    text
    <p>The is the code for the fetchRequest in viewDidLoad and the code is followed from a tutorial found <a href="http://www.raywenderlich.com/934/core-data-tutorial-getting-started" rel="nofollow">here</a> just that I'm linking the navigation controller and the tableview programmatically instead of using interface builder. The entity ProductInfo exists. However when I run the program I get the error:</p> <pre><code>Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+entityForName: could not locate an NSManagedObjectModel for entity name 'ProductInfo'' </code></pre> <p>I have reset the simulator incase it was an old model but the error still occurs. I have also switched to use a FetchedResultsController but the problem still persists. Is the problem because these fetchedResultsController methods aren't inside the appdelegate? They are currently in a TableViewController. How can I solve this problem?</p> <p>viewDidLoad Method:</p> <pre><code>- (void)viewDidLoad{ NSFetchRequest * fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription * entity = [NSEntityDescription entityForName:@"ProductInfo" inManagedObjectContext:context]; [fetchRequest setEntity:entity]; NSError * error; self.productInfos = [_context executeFetchRequest:fetchRequest error:&amp;error]; [fetchRequest release]; [super viewDidLoad];} </code></pre> <p>ProductInfo.h:</p> <pre><code>@class ProductDetails; @interface ProductInfo : NSManagedObject { @private } @property (nonatomic, retain) NSString * productName; @property (nonatomic, retain) NSString * productPrice; @property (nonatomic, retain) ProductDetails * details; @end </code></pre> <p>FetchedResultsController</p> <pre><code>-(NSFetchedResultsController *)fetchedResultsController { if (_fetchedResultsController != nil) { return _fetchedResultsController; } NSFetchRequest * fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription * entity = [NSEntityDescription entityForName:@"ProductInfo" inManagedObjectContext:_context]; //line that is causing the problem [fetchRequest setEntity:entity]; NSSortDescriptor * sort = [[NSSortDescriptor alloc] initWithKey:@"productInfos.productName" ascending:YES]; [fetchRequest setSortDescriptors:[NSArray arrayWithObject:sort]]; [fetchRequest setFetchBatchSize:20]; NSFetchedResultsController * theFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext: _context sectionNameKeyPath:nil cacheName:@"Root"]; self.fetchedResultsController = theFetchedResultsController; _fetchedResultsController.delegate = nil; [sort release]; [fetchRequest release]; [theFetchedResultsController release]; return _fetchedResultsController; </code></pre> <p>}</p> <p>Any help much appreciated.Thanks in advance.</p> <p>In case the above fragments i pasted did not help, I attached the whole project with the data model inside too.</p> <p><a href="http://www.mediafire.com/?5cns4q0sv9hqn6s" rel="nofollow">http://www.mediafire.com/?5cns4q0sv9hqn6s</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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