コメントアウトしたいくつかの行でこのエラーが発生していますが、なぜこの問題が発生するのだろうか? これを修正する最善の方法は何ですか?
場所は CoreData エンティティであり、目印はその属性の 1 つです。
前もって感謝します。
LocationsViewController.m
#import "LocationsViewController.h"
#import "Location.h"
@interface LocationsViewController ()
@end
@implementation LocationsViewController{
NSArray *locations;
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Location" inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];
NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"date" ascending:YES];
[fetchRequest setSortDescriptors:[NSArray arrayWithObject:sortDescriptor]];
NSError *error;
NSArray *foundObjects = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];
if (foundObjects == nil) {
FATAL_CORE_DATA_ERROR(error);
return;
}
locations = foundObjects;
}
- (void)viewDidUnload
{
[super viewDidUnload];
locations = nil;
}
#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [locations count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Location"];
UILabel *descriptionLabel = (UILabel *) [cell viewWithTag:100];
descriptionLabel.text = @"If you can see this";
UILabel *addressLabel = (UILabel *)[cell viewWithTag:101];
addressLabel.text = @"%@ %@, %@",
location.placemark.subThoroughfare, // Use of undeclared identifier 'location'
location.placemark.thoroughfare, // Use of undeclared identifier 'location'
location.placemark.locality ]; // Use of undeclared identifier 'location'
return cell;
}
@end