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-02-2009, 09:29 AM   #2 (permalink)
wyattbiker
Registered Member
 
Join Date: Feb 2009
Posts: 18
wyattbiker is on a distinguished road
Default

Quote:
Originally Posted by stirkles17 View Post
Hi...

I am currently in the process of making an application which relys on a single button to change which label is viewed... but thats not where I am stuck...

I don't want the app to be a 50/50 answer... i want the probability of one of the labels showing up to be far less than the other...

anyone got any ideas or places where i can implement this method as I would like to get my app finished soon so that I can catch the new school year rush...

thanks guys
You need 2 things. One make an IBAction method that runs when the button is pressed and executes your label changing code and wire it up to the Interface Builder button that will be clicked. And you need to randomly get the label and save it in the the labels text field.
For random use the int r = arc4random() % 100;
to get a random between 0 and 99;

Then use your if statement to determine which title gets shown more frequently.

// Show A 75% of the time
if (r<75) label.text="A"; else label.text="B";
wyattbiker is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,180
Threads: 93,920
Posts: 402,153
Top Poster: BrianSlick (7,967)
Welcome to our newest member, mausumi
Powered by vBadvanced CMPS v3.1.0

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