宣言されていない識別子があるというフラグがコンパイラによって付けられていますが、この問題を修正する最善の方法は何でしょうか?
plist を使用してデータを保存するのはこれが初めてなので、最善のアプローチが何であるかわかりません。ありがとうございました。
エラーメッセージをコメントアウトしました:
Destination.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
Destination.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