开发者

how to convert string to int in objective c

开发者 https://www.devze.com 2022-12-12 09:59 出处:网络
i am trying to display annotations in map. I have the lat and longi in string format. now i just need to convert it to int.

i am trying to display annotations in map. I have the lat and longi in string format. now i just need to convert it to int.

    NSString *s= @"18.65799";
    location1.latitude =[s intValue];
    NSLog(@"1%d",[s intValue]);
            NSString *s1= @"73.774262";
    location1.longitude=[s1 intValue];

But when i display [s intValue]the out put is 118. and output for NSLog(@"1%@",location1.latitude) is null;

Plea开发者_如何学Pythonse help.


Change:

NSLog(@"1%d",[s intValue]);

to:

NSLog(@"%d", [s intValue]);

Similarly for s1:

NSLog(@"%d", [s1 intValue]);
0

精彩评论

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