开发者

parsing a float from web-service with JSON

to parse a NSString i have used this :

NSString *adress=[stations objectForKey:@"adress_station"];

what about a float, how should i call it, i try to do that :

       fl开发者_JAVA技巧oat distance=[stations objectForKey:@"distance"];

but i have got an error :

incompatible type in initialization

i don't want to put it in NSString, i need it as float because i need it in other operations :)


float distance = [[stations objectForKey:@"distance"] floatValue];

objectForKey returns an object (in this case I assume an NSString).

Calling -floatValue on an NSString will get the data as a float.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜