0
これまでのところ私が持っている:どのように適切にファイルからデータを読み込むことにより、配列の配列を作成するための
//read in data from CSV file and separate it into 'row' strings:
// where dataString is simply a CSV file with lines of CSV data
// 31 lines with 9 integers in each line
NSArray *containerArray = [dataString componentsSeparatedByString:@"\n"];
NSArray *rowTemp; //local variable just for my sake
NSMutableArray *tableArray;//mutable array to hold the row arrays
//For each index of containerArray:
//take the string object (string of CSV data) and then,
//create an array of strings to be added into the final tableArray
for (int i = 0; i < [containerArray count]; i++) {
rowTemp = [[containerArray objectAtIndex:i] componentsSeparatedByString:@","];
[tableArray addObject:rowTemp];
}
私は次のことをしようとすると、その後、それが返されます(ヌル)
NSLog(@"Row 6, cell 1 is %@", [[tableArray objectAtIndex:5] objectAtIndex:0]);
を何か案は?そこには良い方法がありますか?
FYIこのデータは静的であり、ほとんど変更されません。変更可能な配列を使用するのではなく、静的な配列を作成して作成する方法は、非常に高く評価されます。
ありがとうございます。
私はちょうど答えを得ました! iPhoneSDKフォーラムの助けを借りて、私がしなかったことは実際にはtableArrayを作成することでした。私が上記のコードで行ったことは単に変数を作成することでした。 NSMutableArray * tableArray; 実際には私が望む可変配列を作成しませんでした。代わりに私がしなければならなかったのは: NSMutableArray * tableArray = [NSMutableArray arrayWithCapacity:[containerArray count]]; どれが魅力的であったか。 –