Discuss random generated number view at the iPhone Developer Exchange - Hackint0sh.org; hi this may be considered a dumb question it just that iv been going around ...
-
random generated number view
hi this may be considered a dumb question it just that iv been going around in circles for a bit now and im sure the solution is simple. i was playng around with an idea. in a single lable in a view when the view appears a random number is displayed. presently i have aview, a lable and a button. press button random number is generated and the lables title is replaced with a random number....random number displayed.
what i wish to acheive is that there is no button, just a view and a text lable and when the view appears a random number is displayed also instantaneously with out the need for a button to prompt generation.
here isi the code i have so far
#import "Mainview.h"
@implementation Mainview
- (IBAction)pushstart {
NSString *title = nil;
NSString *path = nil;
int Number = arc4random() % 12;
switch(Number) {
case 0:
namel.text = @"1";
break;
case 1:
namel.text = @"2";
break;
case 2:
namel.text = @"3";
break;
case 3:
namel.text = @"4";
break;
case 4:
namel.text = @"5";
break;
case 5:
namel.text = @"6";
break;
case 6:
namel.text = @"7";
break;
case 7:
namel.text = @"8";
break;
case 8:
namel.text = @"9";
break;
case 9:
namel.text = @"10";
break;
case 10:
namel.text = @"11";
break;
case 11:
namel.text = @"12";
break;
break;
default:
break;
}
}
@end
-
-
you will find an example for generate a random number in this site at Download examples
Cocoa® Programming for Mac® OS X (3rd Edition)
-
Similar Threads
-
By Poe408 in forum General
Replies: 2
Last Post: 08-10-2009, 11:45 PM
-
By jjgraz in forum iPhone Developer Exchange
Replies: 0
Last Post: 03-07-2009, 11:54 PM
-
By TitanMod in forum iPhone Developer Exchange
Replies: 1
Last Post: 07-25-2008, 02:12 PM
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks