Multi dimensional arrays, indexing items
Multi dimensional arrays, indexing items
- Subject: Multi dimensional arrays, indexing items
- From: Mark Wridt <email@hidden>
- Date: Fri, 3 Aug 2001 14:16:34 -0700 (PDT)
Thanks to all who helped with the file parsing
question, and indeed it did help.
But the issue I don't understand is concerning how I
would point to a specific element inside of a specific
array, for example:
The file parsing code:
//init string with file contents
NSMutableString *contentsOfFile = [[NSString alloc]
initWithContentsOfFile:path];
//init array and separate by '\n'
NSArray *listItems = [contentsOfFile
componentsSeparatedByString:@"\n"];
//loop through and create field arrays
for ( i = 0; i <= [listItems count] ; i++){
fields = [[listItems objectAtIndex: i]
componentsSeparatedByString: @"\t"];
NSLog (@"fields = %@", fields);
}
This creates output (in the log)in the form of:
Aug 03 16:01:57 attempt[3719] fields = (Bill, 6542, S,
06R, 4, 4, 32.634, E, "+", 20010625, 100, Miles)
Aug 03 16:01:57 attempt[3719] fields = (Fred, 6550, S,
06R, 4, 4, 32.634, E, "+", 20010625, 100, Miles)
...
The Problem:
I need to be able to point to and compare or calculate
an element in (C++-like) fields[i][j], that is,
"Bill" is in fields[1][1] and "6550" is fields[2][2]..
I noticed there wasn't an "NSVector" API, so I am at a
loss. Can anyone help?
Thanks again, and Cheers (it's Friday!),
Mark
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/