私は合成されたNSMutableArray - theResultArrayを持っています。 NSNumberまたはNSIntegerオブジェクトを特定のインデックス(0-49)に挿入したい。何らかの理由で私の配列に固執する値は決して得られません。 viewDidLoadでIのalloc-initをtheResultsArrayゼロまたは0目的のC配列にオブジェクトをインデックスに追加する
NSInteger timeNum = time;
[theResultArray insertObject:[NSNumber numberWithInt:timeNum] atIndex:rightIndex];
NSLog(@"The right index is :%i", rightIndex);
NSLog(@"The attempted insert time :%i", time);
NSNumber *testNum = [theResultArray objectAtIndex:rightIndex];
NSLog(@"The result of time insert is:%i", [testNum intValue]);
すべてのインデックスを返します。時間は整数です。私は上記のコードのさまざまな組み合わせを無駄にしようとしています。
コンソール出力する:
StateOutlineFlashCards[20389:20b] The right index is :20
StateOutlineFlashCards[20389:20b] The attempted insert time :8
StateOutlineFlashCards[20389:20b] The result of time insert is:0
時間が整数の場合、なぜ整数でもtimeと等しいtimeNumが必要なのでしょうか? – mk12
私は客観的なcとココアをよく知っていません。おそらく、NSIntegerオブジェクトが目的のc intよりもうまく動作すると思いました。 – Bryan
私は以下の回答にすべて変更を加えましたが、私はまったく同じ結果を得ています。 – Bryan