-2

Possible Duplicate:
Generate a random alphanumeric string in cocoa

I'm new to objective c and I would like to add the following functionality to my app:

I have a label which has default text after the app launches. I want for that label to change to a random string each time the user clicks a button. It does not matter if the string repeats itself eventually, as long as it is random.

I appreciate the help in advance.

Community
  • 1
  • 1
Klos225
  • 23
  • 2

1 Answers1

1

You can use following code :

[[NSProcessInfo processInfo] globallyUniqueString]; 

for generating the random string.

or

You can create array that contains number of strings. Assuming you created 10 strings and put them in an array then:

int rand= arc4random()%10 
NSString *str=[array objectAtIndex:rand];
codingNinja
  • 371
  • 2
  • 18
V-Xtreme
  • 7,230
  • 9
  • 39
  • 79