Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get first value from NSMutableArray (iPhone)?

Now i am working in simple iphone application, i have stored some value in NSMutableArray like "{54.399, 196}","{-268.246, 273}".so i want to get 54.399 in first indexpath, how to get this, please help me

Thanks in Advance

like image 332
SampathKumar Avatar asked Jun 04 '12 06:06

SampathKumar


1 Answers

It seems you have an Array of Arrays, so it would be:

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

Or using subscripting:

myArray[0][0];

Edit:

Ok you have an Array of NSStrings. To do what you want (get the 53.399) do the following:

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

With subscripting:

NSString *myFinalString = [[myArray[0] componentsSeparatedByString:@","][0];
like image 122
Rui Peres Avatar answered Sep 27 '22 17:09

Rui Peres