I have a text file looking like this :
#AAA:x
12
34
7
...
#BBB:y
-74.7
-33.2
14
...
#CCC:z
32.4
17
...
#END
I’m able to put all of it in one big NSArray (using componentsSeparatedByString:@"\n")
Now I’d like to have:
AAA float NSArray with all the values under the tag #AAA:x;
BBB float NSArray with all the values under the tag #BBB:y; etc..
How can I do this?
To elaborate on my comment, try this:
This should result in an array of string arrays.
So
subarrays[0]will be an array of strings with these elements: 12, 34, 7.subarrays[1][2] will be a string “14”
If you want floats and not strings, you will have to additionally iterate over all the entries and convert them to float. You can use
NSString‘sfloatValuemethod to do that.