KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a fetch request defined within my core data model called "RemainingGaneProjections". I want to execute that fetch request and sort the results by one of the entity's attributes. My code looks like this: NSFetchRequest *projectionsRequest = [model fetchRequestTemplateForName:@"RemainingGameProjections"]; NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"confidence" ascending:NO]; [projectionsRequest setSortDescriptors:[NSArray arrayWithObject:sortDescriptor]]; When I try to execute this code it crashes with the following message: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Can't modify a named fetch request in an immutable model.' I have confirmed in the debugger that this crash happens when I execute the setSortDescriptors method on my NSFetchRequest. I haven't been able to figure out why this happens. Any explanations for what is happening here? Is there another approach I should be using when retrieving data that needs to be sorted?
Tags (comma-separated)
Save Edits
Cancel