Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.
nope,there isn't offcal function for shuffling array.Tell you some: 1.random a number or something by including math.h and another header(I forgot,you can google) 2.call a for loop,push every number you randomed into your array what do you think about? send me a feedback
//Use a trick to "sort" the array into random order. //this trick involves using a sort function "randomize" that puts //the items in random order. [randomArray sortUsingFunction: randomize context:NULL];
Replies
1.random a number or something by including math.h and another header(I forgot,you can google)
2.call a for loop,push every number you randomed into your array
what do you think about?
send me a feedback
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome#import "time.h"
...
srand( time(NULL) );
int randomIndex;
for( int index = 0; index < numItems; index++ )
{
randomIndex= rand() % numItems + 1;
[theArray exchangeObjectAtIndex:index withObjectAtIndex:randomIndex];
}
Hopefully that works.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomerandomIndex= rand() % numItems + 1;
If your numItems is 5, you want the randomIndex to be a value from 0 through 4, but by adding 1 you're effectively making it 1 through 5 instead.
- kalx
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeI'm a complete noob at this and don't want to trouble you guys with every question, but I really really appreciate this piece of code! Thank you.
Chris.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesomemy mail:gaoning87@163.com
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeThanks
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome//this trick involves using a sort function "randomize" that puts
//the items in random order.
[randomArray sortUsingFunction: randomize context:NULL];
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeOliver Drobnik
Cocoanetics - Our DNA is programmed in Objective-C.
Linguan makes
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome