0
죄송합니다. 완벽하게 설명 할 수없는 경우. fetchResultController 게터가 있습니다.FetchResultController 객체를 만든 후 fetchRequest를 수정할 수 있습니까?
으로
- (NSFetchedResultsController *)fetchedResultsController
{
if (_fetchedResultsController != nil) {
return _fetchedResultsController;
}
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
// Edit the entity name as appropriate.
NSEntityDescription *entity = [NSEntityDescription entityForName: self.entityName inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];
// Set the batch size to a suitable number.
[fetchRequest setFetchBatchSize:20];
// Edit the sort key as appropriate.
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:keyColumnNamePid ascending:NO];
NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
[fetchRequest setSortDescriptors:sortDescriptors];
NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:@"myCache"];
self.fetchedResultsController = aFetchedResultsController;
self.fetchedResultsController.delegate = self;
// Perform Fetch on Result Controller
NSError *error = nil;
if (![self.fetchedResultsController performFetch:&error]) {
// Replace this implementation with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
return _fetchedResultsController;
}
가 지금은 fetchRequest의 일부 조건 및 속성을 설정하려는 below-. (이 필요한 경우에만.) 나는 this-
-(NSFetchedResultsController *) fetchResultsControllerWithPredicate:(NSPredicate *) predicate{
[self.fetchedResultsController.fetchRequest setPredicate:predicate];
[NSFetchedResultsController deleteCacheWithName:@"myCache"];
NSError *error = nil;
if (![self.fetchedResultsController performFetch:&error]) {
// Replace this implementation with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
return _fetchedResultsController;
}
처럼 다른 방법을 만든 의미 이제 인쇄 할 때 _PFBatchFaultingArray가 아래와 같이 반환됩니다. -
"<LibraryItem: 0xdc22150> (entity: LibraryItem; id: 0xdc208b0 <x-coredata://A1159A80-CA8B-4443-B96C-582BF0DC0290/LibraryItem/p332> ; data: <fault>)",
"<LibraryItem: 0xdc224d0> (entity: LibraryItem; id: 0xdc1c590 <x-coredata://A1159A80-CA8B-4443-B96C-582BF0DC0290/LibraryItem/p290> ; data: <fault>)",
"<LibraryItem: 0xdc22510> (entity: LibraryItem; id: 0xdc1c5a0 <x-coredata://A1159A80-CA8B-4443-B96C-582BF0DC0290/LibraryItem/p224> ; data:<fault>)"
문제 : "data : '<'fault '>'"입니다.
이 코드의 문제점은 무엇입니까? 내가 잘못하고 있니?
도움 주셔서 감사합니다.