13
我有一個在OS3 +下運行得很好的應用程序。但它在OS4下不起作用。我收到以下錯誤信息:'NSFetchedResultsController不支持更改跟蹤和獲取請求的NSDictionaryResultType'
「NSFetchedResultsController不支持更改跟蹤和 獲取請求與NSDictionaryResultType」
是否按門鈴到任何人在這裏?
- (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;
}
在此先感謝。
如果我設置[fetchRequest setResultType:NSManagedObjectResultType]而不是[fetchRequest setResultType:NSDictionaryResultType],我的應用程序正常加載。 ' 但[fetchRequest setReturnsDistinctResults:YES]不再工作,我最終重複!!!! 請求幫助。 :-) – 2010-07-16 08:52:20