NSArrayの初期化と整数の追加に問題があります。これが私のコードで、私が達成しようとしていることについてコメントしました。オブジェクトを追加するとアプリがクラッシュしますが、配列を正しくクリアしているかどうかもわかりません。
//CREATE AND INITIALIZE AN ARRAY
NSArray *ticket;
ticket = [[NSArray alloc] init];
//slotA,slotB,slotC are of type NSInteger that I am trying to add
//to the array (THIS CRASHES)
[ticket addObject:[NSNumber numberWithInt:slotA]];
[ticket addObject:[NSNumber numberWithInt:slotB]];
[ticket addObject:[NSNumber numberWithInt:slotC]];
//I never got to this line of code but I think it has to be wrong
//because this would throw the whole //array away. I dont want it
//to be thrown away I just wanna clear it out but keep it instanciated.
[ticket release];
私はこれを試しましたが、「センチメンタル関数呼び出しがありません」と言っています
NSArray *ticket;
NSString *sltA=[NSString stringWithFormat:@"%d", slotA];
NSString *sltB=[NSString stringWithFormat:@"%d", slotB];
NSString *sltC=[NSString stringWithFormat:@"%d", slotC];
ticket = [[NSArray alloc] initWithObjects:sltA,sltB,sltC];
また、整数を文字列に変更して配列に入れる必要がありますか?