NSArray 활성화 및 정수 추가에 문제가 있습니다. 여기에 내 코드가 있는데, 나는 이것을 달성하기 위해 노력하고 있다고 말했다. 개체를 추가 할 때 내 응용 프로그램이 충돌하지만 배열을 올바르게 지우는 지 알 수 없습니다. NSArray 초기화 및 NSInteger 추가
//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];
나는이 시도,하지만 내가 "는 sentinal 함수 호출이 없습니다"하고 말 또한
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];
, 내가 배열에 넣어하는 문자열로 정수를 변경해야합니까?
나는 이것을 시험해 보았지만, 나는 "sentinal function call이 없다"는 말을했다. NSArray * ticket; \t \t \t \t \t \t \t \t \t \t는 NSString sltA * = [있는 NSString stringWithFormat : @ "가 % d"slotA]; \t \t \t \t \t NSString * sltB = [NSString stringWithFormat : @ "% d", slotB]; \t \t \t \t \t NSString * sltC = [NSString stringWithFormat : @ "% d", slotC]; \t \t \t \t \t \t \t \t \t \t 티켓 = [NSArray를 ALLOC의] initWithObjects : sltA, sltB, SLTC]; 또한 배열에 넣으려면 문자열을 정수로 변경해야합니까? –