在最新的 LLVM 版本中,综合属性的要求已被删除。
因此我能够删除我所有的@synthesize
声明,除了以下声明NSFetchedResultsController
。有谁知道为什么当我删除时编译器会警告我@synthesize fetchedResultsController;
line?
Error:
使用未声明的标识符“fetchedResultsController”,您的意思是_fetchedResultsController吗?
这是我的代码:
@property (nonatomic, strong) NSFetchedResultsController *fetchedResultsController;
@synthesize fetchedResultsController;
- (NSFetchedResultsController *)fetchedResultsController {
if (fetchedResultsController) {
return fetchedResultsController;
}
if (!self.managedObjectContext) {
self.managedObjectContext = [(MyAppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext];
}
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Session" inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];
[fetchRequest setPredicate: self.predicate];
[fetchRequest setFetchBatchSize:20];
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"timeStamp" ascending:NO];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
[fetchRequest setSortDescriptors:sortDescriptors];
fetchedResultsController= [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:nil];
fetchedResultsController.delegate = self;
NSError *error = nil;
if (![fetchedResultsController performFetch:&error]) {
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
return fetchedResultsController;
}
当你不放一个@synthesize
在您的代码中,为支持属性而创建的实例变量被命名为_propertyName
。您指的是实例变量fetchedResultsController
删除后不再存在@synthesize
。相反,将所有引用更改为fetchedResultsController
to _fetchedResultsController
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)