I am having problems initalizing an NSArray and adding integers to it here is my code below which I commented in what I am trying to accomplish can someone help me fix it? my app crashes when adding an object, but I dont know if I am clearing the array correctly either.
//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];
I tried this,but its saying I am "missing a sentinal function call"
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];
Also, do I have too change the integers to string to put them in an array?