Reputation: 10713
I'm trying to learn Objective C
with examples, and now I stuck with the following problem. I have a code:
#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
And implementation:
- (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);
}
But values in logs output are nulls. What's wrong?
Upvotes: 0
Views: 46
Reputation: 237010
The format specifier "%@" is for objects, but the variables here are doubles. You want "%f" instead.
Upvotes: 5