开发者

converting double into NSNumber using [NSNumber numberWithDouble:]

开发者 https://www.devze.com 2023-01-26 12:26 出处:网络
there is a coordinate object with three variables latitude(NSNumber) ,longitude(NSNumber) and time(NSDate),for checking the program on my simulator,i gave the folowing code

there is a coordinate object with three variables latitude(NSNumber) ,longitude(NSNumber) and time(NSDate),for checking the program on my simulator,i gave the folowing code

[coordinate setLatitu开发者_如何学JAVAde:[NSNumber numberWithDouble:23.234223]];
[coordinate setLongitude:[NSNumber numberWithDouble:73.234323]];

however when i NSLog coordinate.latitude and coordinate.longitude,it diplays 0.00000

NSLog(@"cordlat :  %f",coordinate.latitude);
NSLog(@"cordlong :  %f",coordinate.longitude);

what can be the problem???


You can't print an NSNumber with %f. You can do one of the following:

  1. NSLog(@"cordlat : %@", coordinate.latitude);
  2. NSLog(@"cordlat : %f", coordinate.latitude.doubleValue);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号