Well, first you need to declare a
mutable array and synthesise it. Then you need a butten was clicked method, looking something like this:
objc code:
- (IBAction)buttonWasClicked:(id)sender {
int size = [usedNumbers count];
if (size > 0) {
int position = (arc4random() % size);
// Finally, remove it from the array:
[usedNumbers removeObjectAtIndex:position];
} else {
// The array is empty.
}
}
then you need to take care of the NIB like this
objc code:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Create two arrays and make the pointers point to them
TheArray = [NSMutableArray array];
}
return self;
}
then you need a output method for your text label, looking something like this
objc code:
- (IBAction)TextFieldMethod:(id)sender
{
int sizeSomething = [TheArray count];
int position2 = (arc4random() % sizeSomething);
// Step to the next question
NSString *randomText = [TheArray objectAtIndex:position2];
// Am I past the last question?
// Get the string in the current index of the questions array
// Output the question string to the debug console
// Display the string in the question text field
[TextField setText:randomText];
}
Hope this helped,

PS. you can't just copy the code directly, you most likely have to personalise it a bit for your own use, but I don't have you project so i tried to generalise it for you
