I'm trying to create a data storage for my application using CoreData. From what I know, Xcode 8 CoreData is using persistentContainer
instead of managedObjectContext
.
I've created a data model with my required entities and created an NSManagedObject
subclass from the Editor menu.
My problem is that when I want to use the persistentContainer
, there is no identifier found.
#import "UserCredentials+CoreDataClass.h"
//Fetch all username to array
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc]initWithEntityName:@"UserCredentials"];
NSError *requestError = nil;
//I couldn't find the persistent container even though I had imported my header file.
NSArray *usernames = [self.persistentContainer.viewContext executeFetchRequest:fetchRequest error:&requestError];
I realised that my CoreDataClass did not even have the property persistentContainer
at all. Where can I declare this at, so I can access my data storage?