将号码添加到NSNumber

时间:2012-11-19 07:54:34

标签: ios math nsnumber

我想+和 - 当前经度的一些值:

NSNumber *Latitude = [[NSNumber alloc] initWithDouble:location.latitude];
NSNumber *Longitude = [[NSNumber alloc] initWithDouble:location.longitude];

NSLog(@"Numbers:%@ %@", Latitude, Longitude);

2012-11-19 08:31:52.740 SR Navigatie[16748:907] Numbers:52.17401375095112 4.98983223979254

我想为LatMin,LatMax,LonMin,LonMax制作NSString或NSNumber。

所以对Latmin我想 - 0.005, LatMax +0.005, LonMin -0.005, LonMax +0.005。

有谁知道如何做到这一点。

提前致谢

1 个答案:

答案 0 :(得分:2)

这不是这么简单吗?

NSNumber *latMin  = [[NSNumber alloc] initWithDouble:location.latitude -0.005];
NSNumber *latMax = [[NSNumber alloc] initWithDouble:location.latitude +0.005];
NSNumber *lonMin = [[NSNumber alloc] initWithDouble:location.longitude -0.005];
NSNumber *lonMax = [[NSNumber alloc] initWithDouble:location.longitude +0.005];