How to get the first value from NSMutableArray (iPhone)?

Now I work in a simple iphone application, I saved some value in NSMutableArrayhow "{54.399, 196}","{-268.246, 273}"., so I want to get 54.399 in the first indexpath, how to get it, please help me

Thanks at Advance

+5
source share
2 answers

It seems you have an array of arrays, so this will be:

[[myArray objectAtIndex:0] objectAtIndex:0];

Or using a subscription:

myArray[0][0];

Edit

Ok, you have an array NSStrings. To do what you want (get 53.399), follow these steps:

NSString *myString = [myArray objectAtIndex:0];
NSArray *stringComponents = [myString componentsSeparatedByString:@","];
NSString *myFinalString = [stringComponents objectAtIndex:0];

With signature:

NSString *myFinalString = [[myArray[0] componentsSeparatedByString:@","][0];
+17
source

you can use

[[arrayObj objectAtIndex:0] objectAtIndex:0];
0
source

All Articles