2012-04-19 6 views
0

宣言されていない識別子を持つためにコンパイラによってフラグが立てられていますが、この問題を解決する最善の方法は何ですか?宛先ファイルで宣言されていない識別子を使用する

私はデータを格納するために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 

答えて

0

完全destinationImage方法を削除します。あなたはすでにそれを合成しているので、それはうまくいくはずです。

+0

ありがとうございます。これを行ったことがありますが、他の変数(destinationCoordinateなど)で同じエラーが発生しています。ローカル変数として宣言する必要がありますか? – pdenlinger

+0

@pdenlingerもしそれらが同じ問題なら、同じ解決策が私が推測するでしょう。 – trojanfoe

関連する問題