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 > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 12-05-2009, 05:49 PM   #1 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 5
Default Pick unique image from array problem

Hi, i have 50 images, when the user press a button (i need help with the following) - 1.create an array of the filenames (imageBall1, imageBall2 ...). 2.pick one random image. 3.pass the selected image to the object ball in this code (ball1 is a UIImageView):
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5]; CGPoint destination = CGPointMake(100,100); ball1.center = destination; [UIView commitAnimations];

4.repeat this process 6 times but each time pick a unique image (that didn't get picked in this event) and do it each time for a different object (ball1, ball2... ball6).

i have the following code that possibly help:

//create an array of filenames
NSMutableArray *imageArray;
for (int c=0;c<2;c++)
{
NSString *imageName = [NSString stringWithFormat:@"name%d.png", c];
[imageArray addObject: imageName];
}

//pick one filename
int numFileNames = [imageArray count];
int chosen = arc4random() % numFileNames;
NSString *oneFilename = [imageArray objectAtIndex: chosen];

thanks!!
omri is offline   Reply With Quote
Reply

Bookmarks

Tags
image, nsmutablearray, uiimage

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 296
19 members and 277 guests
ADY, AragornSG, BrianSlick, Dani77, Dattee, dre, glenn_sayers, HDshot, HemiMG, JasonR, karlam963, prchn4christ, Rudy, spiderguy84, themathminister, tomtom100, viniciusdamone, vogueestylee, vvenkatachallam
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,884
Threads: 89,229
Posts: 380,763
Top Poster: BrianSlick (7,129)
Welcome to our newest member, karlam963
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:18 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0