有这样的字典
[states setObject:@"60.050043,30.345783" forKey:[NSString stringWithFormat:@"Distance is %f km", (betweenDistance3 / 1000)] ];
将字典的值传输到另一个视图,并从意义setObject: @ "60.050043,30.345783"
获取变量大写(NSString
)。我认为这个变量应该传递给CLLocationCoordinate2DMake
(60.050043,30.345783);只能传输数值两个参数。我拿一个可变资本,然后分享
NSString* sourceString = capital;
NSArray* words = [ sourceString componentsSeparatedByString: @"," ];
但是如何将数组转换为两个nsnumber类型的变量?
答案 0 :(得分:1)
一种方法是在doubleValue
数组中的两个NSString
中的每一个上调用words
,并从中创建NSNumber
,如下所示:
NSNumber *first = [NSNumber numberWithDouble:[words[0] doubleValue]];
NSNumber *second = [NSNumber numberWithDouble:[words[1] doubleValue]];