By way of additional info that I realized I should show you, here's the main issue:
self.myInfoMO = [NSEntityDescription
insertNewObjectForEntityForName:@"MyInfo"
inManagedObjectContext:self.managedObjectContext];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"MyInfo" inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];
// Specify criteria for filtering which objects to fetch
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"correct_number == %@", @3];
[fetchRequest setPredicate:predicate];
// Specify how the fetched objects should be sorted
// NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"" ascending:YES];
// [fetchRequest setSortDescriptors:[NSArray arrayWithObjects:sortDescriptor, nil]];
NSError *error = nil;
NSArray *fetchedObjects = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];
if (fetchedObjects != nil && fetchedObjects.count > 0)
{
// Fill Fields with Data
// Is data returned in myInfoMO, or in fetchedObjects?
// And if in fetchedObjects, what structure/fields/objects?
self.myButton.correctValue = self.myInfoMO.correct_number;
}
When I've corrected the NSPredicate to the version you've shown above, I do get a response of fetchedObjects.count = 1. So I'm getting data returned. And I know the correct_number value is 3, from what I entered and then verified by looking at the SQLite database with SQLite Datum (I use this to verify the data actually saved from my entry function which is working OK).
The myInfo.correct_number is defined in the data model as an Integer64.
the myButton.correctValue property is defined as an NSNumber.
After checking the fetch to the myButton.correctValue property/variable, I see it has a value of (long) ). Is it possible that this is an incorrect use of Integer64 to NSNumber conversion? Do I need to change the property type to a long or an NSInteger? (I'll try this in the meantime to see what I can figure out.)
I guess I'm now unsure of whether the issue is my CoreData code or my property/column definitions.
Thanks NotMyName!