take out objects from randomizer obj c
- by David Pollak
hello everyone,
I'm a new "developer" trying to build some iPhone app
I'm making an app which gets text from a list of objects in a NSArray and then randomizes them and display one in a TextView, here's the code:
- (IBAction)azione{
NSArray *myArray= [NSArray arrayWithObjects: @"Pasta",@"Pizza",@"Wait",@"Go", nil];
int length = [myArray count];
int chosen = arc4random() % length;
testo.text = [myArray objectAtIndex: chosen];
}
what I want to do now, is when I open the app and get a random object, to take it out from the list, so that it won't be picked again
ex. I open the appI get "Pizza"Do the action againI don't get "Pizza" anymore, only "Pasta" "Wait" and "Go"
What should I do ? Which code should I use ?
Thanks for answers