简体   繁体   中英

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

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];

您可以使用

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM