tags:

views:

18

answers:

3

In array I do have two values value1="234.3423" value2="12.60348" i need to pass this value to varable double x, double y;

How to do this

Thanks in advance.

+3  A: 

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 NSScanner.

DarkDust
double x=[[myArrayList objectAtIndext:1] doubleValue]; double y=[[myArrayList objectAtIndext:2] doubleValue]; Do i do like this .
kiran kumar
@kiran kumar: Yes, that's perfectly fine. But note that indexes start with 0. So the first element in the array has index 0, the second 1, etc.
DarkDust
okay Dark Dust.... thanks
kiran kumar
A: 

Also see this related question.

zoul
A: 
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.

kiran kumar