An initial object is created, inserted into the ManagedObjectContext, and the context is saved. This object is then set as a property of the singleton class that manages the CoreData stack.
This original object, when referenced from another class, is of the wrong type (NSCFString). On the other hand, if the object is fetched, then it is the correct class and works fine.
NSArray *pdaSetupRecords = [results fetchedObjects];
//If this is the initial launch of the application, create
//a PDASetup object and save the context, otherwise set
//pdaSetup to the fetched instance.
if ([pdaSetupRecords count] < 1) {
PDASetup *newPdaSetup = (PDASetup *) [NSEntityDescription insertNewObjectForEntityForName:@"PDASetup" inManagedObjectContext:managedObjectContext];
[self saveContext];
pdaSetup = newPdaSetup;
NSLog(@"SystemUtility - PDASetup object created and saved.");
} else {
pdaSetup = [pdaSetupRecords objectAtIndex:0];
}
There will be only one PDASetup object as you can see. The problem occurs when when the PDASetup object is created. If I re run the app, and the PDASetup object is fetched, everything is fine.
Any thoughts?
Do you mean to write:
or
Is your app crashing telling you the type is a NSCFString? Probably the memory address was overwritten with a string.