Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't get data from my core-data database
    primarykey
    data
    text
    <p>I am always getting my data from my webservice on the same way. It always worked. But now I am getting this error.</p> <pre><code>*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+entityForName: nil is not a legal NSManagedObjectContext parameter searching for entity name 'Team'' </code></pre> <p>It is crashing in this method.</p> <pre><code>- (NSMutableArray *)getDoelmannen { NSLog(@"tot hier doelman"); NSArray *results = [[NSArray alloc]init]; NSFetchRequest *request = [[NSFetchRequest alloc] init]; [request setEntity:[NSEntityDescription entityForName:@"Team" inManagedObjectContext:self.genkDatabase.managedObjectContext]]; request.predicate = [NSPredicate predicateWithFormat:@"position ==[c] %@", @"Doelman"]; NSLog(@"predicate is: %@",request.predicate); NSError *error = nil; NSLog(@"tot hier"); results = [self.genkDatabase.managedObjectContext executeFetchRequest:request error:&amp;error]; return [results valueForKey:@"image"] ; } </code></pre> <p>For opening my database I use the following methods.</p> <pre><code>-(void)viewWillAppear:(BOOL)animated { if (!self.genkDatabase) { // we'll create a default database if none is set NSURL *url = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]; url = [url URLByAppendingPathComponent:@"Default appGenk Database"]; self.genkDatabase = [[UIManagedDocument alloc] initWithFileURL:url]; // setter will create this for us on disk } } - (void)setGenkDatabase:(UIManagedDocument *)genkDatabase { if (_genkDatabase != genkDatabase) { _genkDatabase = genkDatabase; [self useDocument]; } } - (void)useDocument { if (![[NSFileManager defaultManager] fileExistsAtPath:[self.genkDatabase.fileURL path]]) { // does not exist on disk, so create it [self.genkDatabase saveToURL:self.genkDatabase.fileURL forSaveOperation:UIDocumentSaveForCreating completionHandler:^(BOOL success) { NSLog(@"bestaat niet"); [self getTeam]; }]; } else if (self.genkDatabase.documentState == UIDocumentStateClosed) { // exists on disk, but we need to open it [self.genkDatabase openWithCompletionHandler:^(BOOL success) { NSLog(@"closed"); [self getTeam]; }]; } else if (self.genkDatabase.documentState == UIDocumentStateNormal) { // already open and ready to use NSLog(@"Normal"); [self getTeam]; } } </code></pre> <p>Can anybody help me? </p> <p>Kind regards.</p> <p><em><strong>EDTI</em></strong></p> <p>It's very strange because when I test the method in anohter viewcontroller it works. The only difference is in my .h file I do this. </p> <pre><code> @interface MultimediaViewController : CoreDataTableViewController </code></pre> <p>And in the viewController where it doesn't works it does this.</p> <pre><code>@interface MultimediaViewController : NRGridViewController </code></pre> <p>But I still did import it like this.</p> <pre><code>#import "CoreDataTableViewController.h" </code></pre>
    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.
    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