I have an application that was running just fine under OS3+. But it does not work under OS4. I get the following error message:
'NSFetchedResultsController does not support both change tracking and
fetch request's with NSDictionaryResultType'
Does it ring a bell to anyone here?
- (NSFetchedResultsController *)fetchedResultsController {
if (fetchedResultsController != nil) {
return fetchedResultsController;
}
/*
Set up the fetched results controller.
*/
// Create the fetch request for the entity.
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
// Edit the entity name as appropriate.
NSEntityDescription *entity = [NSEntityDescription entityForName:@"myEntity" inManagedObjectContext:managedObjectContext];
[fetchRequest setEntity:myEntity];
[fetchRequest setResultType:NSDictionaryResultType];
[fetchRequest setPropertiesToFetch :[NSArray arrayWithObjects:@"FIELD1",@"FIELD2",@"FIELD3",@"FIELD4",@"FIELD5",nil]];
// Setting unique values
[fetchRequest setReturnsDistinctResults:YES];
// Edit the sort key as appropriate.
NSSortDescriptor *initialDescriptor = [[NSSortDescriptor alloc] initWithKey:@"FIELD1" ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:initialDescriptor, nil];
[fetchRequest setSortDescriptors:sortDescriptors];
// Edit the section name key path and cache name if appropriate.
// nil for section name key path means "no sections".
NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:@"FIELD1" cacheName:@"myCache"];
aFetchedResultsController.delegate = self;
self.fetchedResultsController = aFetchedResultsController;
[aFetchedResultsController release];
[fetchRequest release];
[initialDescriptor release];
[sortDescriptors release];
return fetchedResultsController;
}
Thanks in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…