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

  • SEARCH
  • Home
  • 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 859819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:43:46+00:00 2026-05-15T08:43:46+00:00

I have some class methods in a class with a pretty long name (TimingConfigController

  • 0

I have some class methods in a class with a pretty long name (TimingConfigController to be exact), and I call those methods quite often from within the class (example: [TimingConfigController intervalStringAt:i]), but the long class name bothers me because the statements get very long and less readable with all that inlined.

I was reading up to see if I could find a shorthand alternative, and I came upon this article on developer.apple.com:
Defining a Class

It says, among other things, that

id newInstance = [[self alloc] init];

is an excellent way to make an object of the same class that self is. As far as I can tell, that statement calls a class method using the self pointer instead of the class name, so I tried that in my app, and although it might work, it gives a compiler warning. I really don’t want to have warnings.

So, my questions are, is using self to call a class method possible and/or a good idea? Are there any better alternatives? Would it be terrible of me to do a #define Self TimingConfigController at the start of the .m file? Or should I just take my meds and live with the annoyances?

  • 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-15T08:43:47+00:00Added an answer on May 15, 2026 at 8:43 am

    self only represents a class inside a class method. Because the target of a class method is a class, self represents the class.

    For example, inside an + (void)initialize method, it is common to see:

    + (void)initialize {
        if (self == [MyClass class]) { // <- self is the current class
            // ...
        }
    }
    

    If you really want to shorten the class name without renaming it, the simplest solution is to use a #define statement:

    #define TCC TimingConfigController
    
    // The two lines are equivalent
    id result1 = [TimingConfigController theClassMethod]; 
    id result1 = [TCC theClassMethod];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a class library that will have some public & private methods. I
I have a class with some abstract methods, but I want to be able
I have a class library with some extension methods written in C# and an
I have a base class for many tests that has some helper methods they
I have some code that will be accessed from two threads: class Timer{ public:
Suppose I have some per-class data: (AandB.h) class A { public: static Persister* getPersister();
What exactly are the Python scoping rules? If I have some code: code1 class
I have some classes layed out like this class A { public virtual void
I have some event handler on a boundary class that manages a persistence mechanism
I have some ASP.NET web services which all share a common helper class they

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.