开发者

How to pass string to double from NSMutableArray

In array I do have two values value1="234.3423" val开发者_开发技巧ue2="12.60348" i need to pass this value to varable double x, double y;

How to do this

Thanks in advance.


First, you need to turn them into the number (which you're giving in C string syntax here) into an NSString:

char *value1 = "234.3423";
NSString *string1 = [NSString stringWithUTF8String:value1];

Then, simply do this:

double x = [string1 doubleValue];

That's it. If the simple number parsing of NSString is not enough for you, you will need to look into NSNumberFormatter.


double x=[[myArrayList objectAtIndext:1] doubleValue]; 
double y=[[myArrayList objectAtIndext:2] doubleValue]; 

Hope its works for me :D

If not help me any another easy way.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜