【发布时间】:2014-02-04 06:33:12
【问题描述】:
我使用CLLocation获取当前位置如下:
-(void)loadCurrentLocation{
if (manager==nil) {
manager=[[CLLocationManager alloc]init];
}
manager.delegate=self;
manager.desiredAccuracy=kCLLocationAccuracyBest;
[manager startUpdatingLocation];
}
- (void) viewDidLoad {
[super viewDidLoad];
[self loadCurrentLocation];
}
-(void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation {
CLLocation *loc=newLocation;
if (loc!=nil) {
self.latitude=loc.coordinate.latitude; //1
self.longitude=loc.coordinate.longitude; //2
NSLog(@"Gained Latitude:%.f",self.latitude);
NSLog(@"Gained Longitude:%.f",self.longitude);
}
}
鉴于latitude 和longitude 在.h 文件中声明如下:
@interface Prayers :UIViewController<CLLocationManagerDelegate>
@property double longitude;
@property double latitude;
@end
问题在于第 1 行和第 2 行的返回值是整数,如 30 和 31,我期待它们像 31.377033600000004000 和 30.016893900000000000,那么为什么返回值是整数而不是 double 呢?在此先感谢
【问题讨论】:
标签: objective-c cocoa-touch ios7 cllocationcoordinate2d