I have a simple entity called "Store" built in Xcode's data modeler for use in an iPhone application. I also have a class (Store) associated with it and I've been able to store and retrieve data using CoreData without any problems.
Now I realized that I want to have a relationship to another entity (Aisle). There is already a one-to-one relationship from Aisle to Store, but since there can be multiple Aisles in one Store, I tried to add the reverse. The new relationship is one-to-many, the inverse of the original one-to-one relationship, optional, and has delete set to cascade. I also recreated the associated Store class so that there is now an NSSet ivar in the class definition as well.
Just adding this relationship causes my existing data to be irretrievable through NSFetchRequest. As I'm debugging I see that the array that is being populated by the request contains zero items, but looking at the SQL database I see that the objects are all there. If I remove the new relationship everything works just fine.
Here is my code to retrieve the data:
NSManagedObjectContext *context = [self managedObjectContext];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Store" inManagedObjectContext:context];
[fetchRequest setEntity:entity];
NSError *error;
NSArray *storesList = [context executeFetchRequest:fetchRequest error:&error];
[fetchRequest release];
Any idea why my fetch isn't working correctly?
Thank you!