Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6742459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:50:45+00:00 2026-05-26T11:50:45+00:00

I am basically trying to make a method that enables me to get random

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:50:46+00:00Added an answer on May 26, 2026 at 11:50 am

    It should be

    [[self randomColour] setStroke];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I posted this elsewhere bus was unable to get help. So basically I'm trying
as I get closer to releasing my app, I'm trying to make sure that
I am developing an app for sending some feedback. Basically I'm trying to make
I recently came across this in some code - basically someone trying to create
I'm trying to make a form that handles the checking of a domain: the
i'm trying to make my own IAuthorizationFilter attribute class. Basically, each api call has
I have a method with an out parameter that tries to do a type
I have a method that looks similar to the following: public void myMethod(MyClass c)
I'm trying to make a pretty simple game and I'm stuck. Basically I want
I'm trying to create an overload of the System.Console.ReadLine() method that will take a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.