Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 09-07-2010, 05:20 AM   #6 (permalink)
kaczg
Registered Member
 
Join Date: Aug 2010
Posts: 3
kaczg is on a distinguished road
Default More Randomness

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.
kaczg is offline   Reply With Quote
 

» Advertisements
» Online Users: 380
12 members and 368 guests
Chickenrig, earnestarvizo, erdinc27, EvilElf, georgiannuo53, ipodphone, joelle883600, LEARN2MAKE, linkmx, Mnadeep, nanijoe, PlutoPrime
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,582
Threads: 94,082
Posts: 402,771
Top Poster: BrianSlick (7,990)
Welcome to our newest member, joelle883600
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:02 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.