2013-10-07 71 views
0

我試圖通過示例學習Objective C,現在我堅持以下問題。我有一個代碼:無法讀取目標C中的類成員值C

#import <UIKit/UIKit.h> 
#import <MapKit/MapKit.h> 

@interface ViewController : UIViewController <MKMapViewDelegate> { 
IBOutlet MKMapView *mapView; 

MKPointAnnotation* startPoint; 
MKPointAnnotation* endPoint; 

double startPointLat; 
double startPointLon; 
double endPointLat; 
double endPointLon; 
} 
@property (strong, nonatomic) IBOutlet MKMapView *mapView; 
- (IBAction)findPressed:(id)sender; 

@end 

與實現

- (void)viewDidLoad 
{ 
[super viewDidLoad]; 
self.mapView.delegate = self; 

// Add an annotation 
startPoint = [[MKPointAnnotation alloc] init]; 
startPoint.coordinate = CLLocationCoordinate2DMake(0, 0); 
startPoint.title = @"Start point"; 

endPoint = [[MKPointAnnotation alloc] init]; 
endPoint.coordinate = CLLocationCoordinate2DMake(10, 10); 
endPoint.title = @"End point"; 

startPointLat = 0; 
startPointLon = 0; 
endPointLat = 10; 
endPointLon = 10; 

[self.mapView addAnnotation:startPoint]; 
[self.mapView addAnnotation:endPoint]; 

NSLog(@"%@, %@ -> %@, %@", startPointLat, self->startPointLon, self->endPointLat, self->endPointLon); 
} 

但在日誌輸出值是空值。怎麼了?

回答

5

格式說明符「%@」用於對象,但這裏的變量是雙精度。你想要「%f」。