[英]Thread1: EXC_BAD_ACCESS(code=2, address=0x7fff5450df68)
I try to fetch data from coredata and display in tableview working with NSFetchResultController but show me error like this 我尝试从coredata获取数据并在使用NSFetchResultController的tableview中显示,但显示出这样的错误
Thread1: EXC_BAD_ACCESS(code=2, address=0x7fff5450df68) objective c 线程1:EXC_BAD_ACCESS(code = 2,address = 0x7fff5450df68)目标c
- (NSFetchedResultsController *)fetchResultController {
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
_mainContext = [appDelegate manageObjectContext];
if (_fetchResultController != nil) {
return _fetchResultController;
}
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Student" inManagedObjectContext:_mainContext];
[request setEntity:entity];
//[request setFetchBatchSize:20];
NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:@"Student.name" ascending:NO];
[request setSortDescriptors:[NSArray arrayWithObject:sort]];
NSFetchedResultsController *theFetchResultController =[[NSFetchedResultsController alloc] initWithFetchRequest:request managedObjectContext:_mainContext sectionNameKeyPath:nil cacheName:@"Root"]; //this point show me error
self.fetchResultController.delegate = theFetchResultController;
return _fetchResultController;
}
Please help to fix this Problem. 请帮助解决此问题。
This problem is occurs through this statement Edit this 通过此语句会发生此问题
self.fetchResultController.delegate = theFetchResultController;
Replace with it. 更换它。
self.fetchResultController.delegate = self
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.