Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
iOS Development
Button Looping and me!
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="anonix" data-source="post: 1290507" data-attributes="member: 213492"><p>Hey guys how is everyone today? I just had a couple questions and wondering if anyone could help.</p><p></p><p>I been trying to write a Xcode 4 cocoa app that is a guessing game. I was able to complete the game in the console, but now that I am trying to link it to a UI I'm finding it not so easy.</p><p></p><p>This is the basic Idea, i know its off. I had it working at one point but every time i hit the button it generated a new random number and i can't figure out how to do it outside the button, and how to add 5 tries before calling game over.</p><p></p><p>[CODE]@implementation LoopingAppDelegate</p><p></p><p>-(void)setStuff:(id)sender{</p><p> NSInteger g = [input];</p><p> NSInteger y;</p><p> NSInteger x = rand() % 100;</p><p> </p><p> </p><p> </p><p>}</p><p></p><p>- (IBAction)run:(id)sender</p><p>{</p><p> [y setIntValue:[x intValue]];</p><p> if([g] intValue] == x){</p><p> [results setStringValue:@"YOU ARE CORRECT SIR!!!"];</p><p> return;}</p><p> else if(guess.intValue < y.intValue){</p><p> [results setStringValue:@"Higher \nGuess again!"];}</p><p> else if(guess.intValue > y.intValue){</p><p> [results setStringValue:@"Lower \nGuess again!"];}</p><p> else {</p><p> [results setStringValue:@"What the **** did you type??!?!"];</p><p> }</p><p>}[/CODE]</p></blockquote><p></p>
[QUOTE="anonix, post: 1290507, member: 213492"] Hey guys how is everyone today? I just had a couple questions and wondering if anyone could help. I been trying to write a Xcode 4 cocoa app that is a guessing game. I was able to complete the game in the console, but now that I am trying to link it to a UI I'm finding it not so easy. This is the basic Idea, i know its off. I had it working at one point but every time i hit the button it generated a new random number and i can't figure out how to do it outside the button, and how to add 5 tries before calling game over. [CODE]@implementation LoopingAppDelegate -(void)setStuff:(id)sender{ NSInteger g = [input]; NSInteger y; NSInteger x = rand() % 100; } - (IBAction)run:(id)sender { [y setIntValue:[x intValue]]; if([g] intValue] == x){ [results setStringValue:@"YOU ARE CORRECT SIR!!!"]; return;} else if(guess.intValue < y.intValue){ [results setStringValue:@"Higher \nGuess again!"];} else if(guess.intValue > y.intValue){ [results setStringValue:@"Lower \nGuess again!"];} else { [results setStringValue:@"What the **** did you type??!?!"]; } }[/CODE] [/QUOTE]
Verification
Post reply
Forums
macOS & iOS Developer Playground
iOS Development
Button Looping and me!
Top