- (NSFetchedResultsController *)fetchedGroupResultsController
{
if (fetchedGroupResultsController == nil)
{
NSManagedObjectContext *moc = [[self appDelegate] managedObjectContext_roster];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"XMPPGroupCoreDataStorageObject"
inManagedObjectContext:moc];
NSSortDescriptor *sd1 = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES];
//NSSortDescriptor *sd2 = [[NSSortDescriptor alloc] initWithKey:@"displayName" ascending:YES];
NSArray *sortDescriptors = [NSArray arrayWithObjects:sd1, nil];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:entity];
[fetchRequest setSortDescriptors:sortDescriptors];
[fetchRequest setFetchBatchSize:10];
fetchedGroupResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
managedObjectContext:moc
sectionNameKeyPath:@"name"
cacheName:nil];
[fetchedGroupResultsController setDelegate:self];
[sd1 release];
//[sd2 release];
[fetchRequest release];
NSError *error = nil;
if (![fetchedGroupResultsController performFetch:&error])
{
NSLog(@"Error performing fetch: %@", error);
}
}
return fetchedGroupResultsController;
}`取XMPPGroupCoreDataStorageObject,但NSManagingContextDidSaveChangesNotification似乎不起作用
我用這個方法來獲取羣組結果,它works.but當我接觸的一個在線或離線時, - (void)controllerDidChangeContent:(NSFetchedResultsController *)controller { [[self tableView] reloadData]; }
方法韓元不會被調用,所以我的表視圖將不會被重新加載,並且狀態不會刷新。我很難過,任何人都可以幫助我?