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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 02-01-2009, 08:53 PM   #14 (permalink)
PhillipJames
New Member
 
Join Date: Feb 2009
Posts: 2
Default Seems to not be random??

I am also a new programmer and every time it runs, I get the same order of answers - I have put 6 values in the array and they appear - 6, 3, 5, 5, 6, 2, 3, 5, 2, 4 ......

I can close the sim, recompile and sure enough they appear in this order everytime.

Any ideas?

==
NSArray *myArray= [NSArray arrayWithObjects: @"1111",@"2222",@"3333",@"4444",@"5555",@"6666" , nil];
int length = [myArray count];

//choose an item - C magic happens here
int chosen = (float)random() * length /RAND_MAX;

NSString *item = [myArray objectAtIndex: chosen];
lblText.text = [NSString stringWithFormat: @"%@", item];
PhillipJames is offline   Reply With Quote
 

» Advertisements
» Online Users: 632
21 members and 611 guests
ADY, AragornSG, Dattee, denied, Duncan C, iDifferent, john love, kapps11, Keys, klrichner, mapiko, peppinoss, Punkjumper, Robiwan, sle39lvr, smithdale87, Speed, spiderguy84, themathminister, timle8n1, wiggi
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,745
Threads: 89,201
Posts: 380,564
Top Poster: BrianSlick (7,129)
Welcome to our newest member, Ashleyk27
Powered by vBadvanced CMPS v3.1.0

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