kiran kumar
kiran kumar

Reputation: 1359

How to pass string to double from NSMutableArray

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.

Upvotes: 2

Views: 3133

Answers (2)

DarkDust
DarkDust

Reputation: 92345

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.

Upvotes: 6

kiran kumar
kiran kumar

Reputation: 1359

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.

Upvotes: 0

Related Questions