Reputation: 699
I am basically trying to make a method that enables me to get random colors for drawing. I have created a method like this:
-(UIColor*)randomColour
{
NSArray *colourArray = [NSArray arrayWithObjects:[UIColor redColor],
[UIColor blueColor],
[UIColor greenColor],nil];
UIColor *colour = [colourArray objectAtIndex:rand()%3];
[colourArray release];
return colour;
}
and I WANT to call it like this
[[UIColor [self randomColour]] setStroke];
or like this
[[UIColor randomColour] setStroke];
but both fails. What is it that I don't understand?
For the second option I get a warning:
"class method '+randomColour' not found"
I have tried reading up on class methods but can't see why it's cussing about it. Any quick pointers?
Thanks
Upvotes: 0
Views: 350
Reputation: 92335
If you have defined randomColour
in your own class, you simply do:
[[self randomColour] setStroke];
Upvotes: 1
Reputation: 10865
Try using
+(UIColor*)randomColour
instead of
-(UIColor*)randomColour
Upvotes: 0