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 6023771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:03:18+00:00 2026-05-23T04:03:18+00:00

Why is using self allowed in static context in Objective-C? I thought it was

  • 0

Why is using self allowed in static context in Objective-C?

I thought it was allowed and then I encountered memory errors that took me a week to find out that self is not an alias for calling other static methods from the class instead of typing the class name.

Xcode and its compiler seems very smart at finding common pitfalls, why isn’t it even generating a warning about something like that?

  • 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-23T04:03:19+00:00Added an answer on May 23, 2026 at 4:03 am
    1. There is no such thing as a “static context” in Objective-C. What we have instead are “class methods”. They definitely are not “static” methods.
    2. Class methods (ones prefixed with a +) are really just instance methods on a particular Class object. (did your mind just explode?) And since you have a self variable accessible in an instance method, you naturally have a self variable accessible in the class method as well.
    3. In a class method, self points to the class itself.
    4. Just as you can do [self performAction] inside an instance method to invoke methods on this particular instance, you can do [self performClassAction] inside a class method to invoke methods on this particular class.
    5. All Class objects are subclasses of NSObject. So you can use any NSObject instance method on any Class object. (did your mind just explode again?)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is using self ever necessary in Objective-C or maybe just a good practice? I
this is the code I'm using: self::$DB->prepare($query, $types); when the $query and types are:
I'm a new Python programmer who is having a little trouble using 'self' in
In PHP 5, what is the difference between using self and $this ? When
I'm using VS1010RC with the POCO self tracking T4 templates. In my WCF update
How do I create a self-signed certificate for code signing using the Windows SDK?
How can I self-sign an iPhone application using Xcode? I have done the following:
I am using this code: NSURLConnection *oConnection=[[NSURLConnection alloc] initWithRequest:oRequest delegate:self]; to download a file,
I have a self built JSP webapp and at the moment I'm using tomcats
I am using UINavigationController to push and pop a view. I used [[self navigationController]

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.