我被编译器标记为具有未声明的标识符,并且想知道解决此问题的最佳方法是什么?
这是我第一次使用 plist 来存储数据,所以我不确定最好的方法是什么。谢谢你。
已注释掉错误消息:
目的地.h
#import "Destination.h"
@implementation Destination
@synthesize coordinate = _coordinate;
@synthesize title = _title;
@synthesize subtitle = _subtitle;
@synthesize destinationName = _destinationName;
@synthesize destinationImage = _destinationImage;
-(id)initWithDestinationIndex:(NSUInteger)destinationIndex {
if (self = [super init]) {
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Destinations" ofType:@"plist"];
NSDictionary *destinations = [NSDictionary dictionaryWithContentsOfFile:filePath];
NSArray *destinationsArray = [destinations objectForKey:@"DestinationData"];
NSDictionary *data = [destinationsArray objectAtIndex:destinationIndex];
self.destinationImage = [UIImage imageNamed:[data objectForKey:@"DestinationImage"]];
self.destinationName = [data objectForKey:@"DestinationName"];
NSDictionary* destinationLocation = [data objectForKey:@"DestinationLocation"];
destinationCoordinate.latitude = [[destinationLocation objectForKey:@"Latitude"]doubleValue];// Use of undeclared identifier 'destinationCoordinate'
destinationCoordinate.longitude = [[destinationLocation objectForKey:@"Longitude"]doubleValue];// Use of undeclared identifier 'destinationCoordinate'
self.coordinate = destinationCoordinate;//Use of undeclared identifier 'destinationCoordinate'
self.title = [destinationLocation objectForKey:@"Title"];
self.subtitle = [destinationLocation objectForKey:@"Subtitle"];
}
return self;
}
-(UIImage *)destinationImage {
return destination.destinationImage;//Use of undeclared identifier 'destination'; did you mean 'Destination'?
}
-(NSString *)destinationName {
return destinationName;//Use of undeclared identifer 'destinationName'; did you mean '_destinationName'?
}
-(CLLocationCoordinate2D)destinationCoordinate {
return destination.coordinate;//Use of undeclared 'destination'; did you mean 'Destination'
}
@end
目的地.h
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
@interface Destination : NSObject<MKAnnotation>
@property(nonatomic,readwrite)CLLocationCoordinate2D coordinate;
@property(nonatomic,readwrite,copy)NSString *title;
@property(nonatomic,readwrite,copy)NSString *subtitle;
@property(nonatomic,strong)NSString *destinationName;
@property(nonatomic,strong)UIImage *destinationImage;
-(id)initWithDestinationIndex:(NSUInteger)destinationIndex;
@end