Any one have a simple answer for a putting a random response in touches?
So I can create a button to push for random responses using arc4Random just fine.
Code:
-(IBAction) dotPressed: (id)sender
{
int num = [answers count];
int chosen = arc4random() % num;
decisionText.text = [answers objectAtIndex: chosen];
}
-(void)viewDidLoad
{
[super viewDidLoad];
answers = [[NSArray alloc] initWithObjects:
@"Yes",
@"No",
@"Maybe", nil];
}
But, for the life of me I am failing to create a random response code as a result of a touchesEnded...withEvent. There must be a simple way.
Right now I can only make one response work when object reaches its target.
I've played with several methods, but have had no success.
Here is the single response code:
Code:
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint touchLocation = [touch locationInView:self.view];
if (CGRectContainsPoint([flower frame], touchLocation))
{
CGRect frame = viewToMove.frame;
switch (activeView)
{
case 0:
response.text = @"No.";
frame.origin.x = 20;
frame.origin.y = 418;
break;
I appreciate the help! I'm so close and I'm sure the answer is simple.
Which random method and where to put it...Hum.