Ganjira
Ganjira

Reputation: 976

How to pick randomly UIColor saved in NSArray?

I saved colors in a NSArray like this:

NSArray *arr = [[NSArray alloc] initWithObjects:[UIColor blackColor], [UIColor darkGrayColor], nil];

The problem is that I don't know how to pick randomly the UIColor from this NSArray.

How to do this?

Thanks in advance.

Upvotes: 1

Views: 480

Answers (1)

Sohaib
Sohaib

Reputation: 11297

[arr objectAtIndex:arc4random() % arr.count];

Upvotes: 3

Related Questions