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-05-2010, 04:13 AM   #21 (permalink)
iphone66
Registered Member
 
Join Date: Feb 2010
Posts: 4
Default image?????

Quote:
Originally Posted by smasher View Post
In general, you want to make an array of your (images / strings,) then pick a random number, then grab that Item from the array. Something like this:

Code:
//create the array
NSArray *myArray= [NSArray arrayWithObjects: @"Yes",@"No",@"File Not Found", nil];
	
//get the length of the array
int length = [myArray count];
	
//choose an item - C magic happens here :)
int chosen = (float)random() * length /RAND_MAX;	
	
//get that item
NSString *item = [myArray objectAtIndex: chosen];
	
//print that item
NSLog(@"The item I picked is: %@", item);
That's 4 bits of cocoa magic, and one bit of plain-old C magic.


it works|||||but i want to display an images randomly.........how to display the image is my question........
iphone66 is offline   Reply With Quote
 

» Advertisements
» Online Users: 350
21 members and 329 guests
ADY, bobli, Dani77, Duncan C, ghost, HDshot, HemiMG, ilmman, MarcoAlmeida, Meoz, ngaikwad, Punkjumper, Raffaello, Robiwan, Rudy, skrew88, themathminister, timle8n1, wilky94
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,877
Threads: 89,222
Posts: 380,727
Top Poster: BrianSlick (7,129)
Welcome to our newest member, peterkessler45
Powered by vBadvanced CMPS v3.1.0

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