EDIT: (For ios)
-(NSDictionary *)randomColorAndLabel{
UIColor *color1= [UIColor colorWithRed:0.2 green:0.4 blue:0.3 alpha:1.0];
UIColor *color2= [UIColor colorWithRed:0.3 green:0.4 blue:0.3 alpha:1.0];
UIColor *color3= [UIColor colorWithRed:0.4 green:0.4 blue:0.3 alpha:1.0];
NSDictionary *colorDict1=@{@"color1" : color1};
NSDictionary *colorDict2=@{@"color2" : color2};
NSDictionary *colorDict3=@{@"color3" : color3};
NSArray *colors=@[colorDict1, colorDict2, colorDict3];
NSInteger randomNumber=arc4random()%3;
return colors[randomNumber];
}
which returns dictionary with color and name that you can use for label.
Earlier solved for OSX
I solved for OSX, with NSColor instead of UIColor and method name is changed as
colorWithRed:randomRed green:randomGreen blue:randomBlue alpha:1.0];
-(NSDictionary *)randomColorAndLabel{
NSColor *color1= [NSColor colorWithCalibratedRed:0.2 green:0.4 blue:0.3 alpha:1.0];
NSColor *color2 = [NSColor colorWithCalibratedRed:0.3 green:0.4 blue:0.3 alpha:1.0];
NSColor *color3= [NSColor colorWithCalibratedRed:0.4 green:0.4 blue:0.3 alpha:1.0];
NSDictionary *colorDict1=@{@"color1" : color1};
NSDictionary *colorDict2=@{@"color2" : color2};
NSDictionary *colorDict3=@{@"color3" : color3};
NSArray *colors=@[colorDict1, colorDict2, colorDict3];
NSInteger randomNumber=arc4random()%3;
return colors[randomNumber];
}
this returns dictionary with name and color.