Which dataType will return the value (37.961498) as it is ? Double didn't work

前端 未结 3 1131
无人共我
无人共我 2021-01-17 06:32

Which dataType will return the value (37.961498) as it is?

I am working in MapView. Where, at present I am setting annotation and hence I have to set CLLocationCoor

相关标签:
3条回答
  • 2021-01-17 06:39

    When converting a string to a double you should be using doubleValue instead of floatValue

    double int1=[num1s doubleValue];
    double int2=[num2s doubleValue];
    NSLog(@" %f %f ",int1,int2);
    annotation.coordinate=CLLocationCoordinate2DMake(int1, int2);
    

    also not critical but I wouldn't recommend naming your doubles as int1 and int2 that is likely to cause you confusion at some point

    0 讨论(0)
  • 2021-01-17 06:50
    annotation.coordinate=CLLocationCoordinate2DMake([nums doubleValue], [int2 doubleValue]);
    

    Try this

    0 讨论(0)
  • 2021-01-17 06:55
    double int1=[num1s floatValue];
    double int2=[num2s floatValue];
    NSLog(@" %0.7f %0.7f ",int1,int2);
    annotation.coordinate=CLLocationCoordinate2DMake(int1, int2);
    

    Read String Format Specifiers for more info.

    0 讨论(0)
提交回复
热议问题