- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
id <NSFetchedResultsSectionInfo> sectionInfo = [[[self fetchedResultsController] sections] objectAtIndex:section];
NSLog(@"numberOfRowsInSection %@", [sectionInfo numberOfObjects]);
return [sectionInfo numberOfObjects];
}
를 앱이이 시점까지 실행 어떻게 든 NSFetchResultsController
-(NSFetchedResultsController*) fetchedResultsController {
if (_fetchedResultsController == nil) {
FlipPadAppDelegate* app = (FlipPadAppDelegate*) [[UIApplication sharedApplication] delegate];
NSFetchRequest* fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:
[NSEntityDescription entityForName:@"FundClass" inManagedObjectContext:[app managedObjectContext]]];
NSSortDescriptor* sortdesp = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES];
[fetchRequest setSortDescriptors:[NSArray arrayWithObject:sortdesp]];
[fetchRequest setFetchBatchSize:20];
_fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
managedObjectContext:[app managedObjectContext]
sectionNameKeyPath:nil
cacheName:@"_Stock"];
_fetchedResultsController.delegate = self;
[fetchRequest release];
[sortdesp release];
NSError *error;
if (![[self fetchedResultsController] performFetch:&error]) {
// Handle error
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
}
}
return _fetchedResultsController;
}
,이 게터 기능이 발생합니다. EXC_BAD_ACCESS
sqllite 데이터베이스에는 두 개의 레코드가 있습니다.
왜 예외입니까? 내가 sectionNameKeyPath
을 nil로 설정했기 때문입니까? 또는 뷰의 dataSource를이 컨트롤러에 설정하지 않았기 때문에? "난 numberOfRowsInSection의 %"대신
@property (nonatomic, readonly) NSUInteger numberOfObjects
사용 @
크래시 로그의 내용은 무엇입니까? – WrightsCS