3

With the latest LLVM build, the requirement for synthesizing properties has been removed.

Therefore I was able to remove all my @synthesize statements except for the ones for NSFetchedResultsController. Does anyone know why the compiler is warning me when I remove the @synthesize fetchedResultsController; line?

Error:

Use of undeclared identifier "fetchedResultsController", did you mean _fetchedResultsController?

This is my code:

@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;
}
4

3 に答える 3

4

コードにを入れない場合@synthesize、プロパティをサポートするために作成されるインスタンス変数の名前は になります_propertyNamefetchedResultsControllerを削除した後に存在しなくなったインスタンス変数を参照しています@synthesize。代わりに、すべての参照を に変更しfetchedResultsControllerます_fetchedResultsController

于 2013-01-07T01:52:25.560 に答える
1

デフォルトの合成変数_fetchedResultsControllerfetchedResultsController

于 2013-01-07T01:52:57.893 に答える
1

プロパティfetchedResultsControllerは に自動的に合成され_fetchedResultsController、これは合成された変数ごとに発生します。

名前を変更するには、明示的に合成する必要があります。

于 2013-01-07T01:53:12.533 に答える