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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:56:19+00:00 2026-05-16T00:56:19+00:00

I am just curious about the role that self plays within an object. I

  • 0

I am just curious about the role that self plays within an object. I understand that writing [[self dataForTable] count] refers directly to the iVar contained in that object. But if you miss self off and directly specify the iVar [dataTable count] how does that differ, what are you protecting against by using self, is it just to uniquely specify an iVar rather than maybe some similar local variable?

@implementation ViewController
@synthesize dataForTable;

...

NSUInteger dataCount = [[self dataForTable] count];

much appreciated

Gary.

  • 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-16T00:56:19+00:00Added an answer on May 16, 2026 at 12:56 am

    Writing [[self dataForTable] count] does not refer directly to the iVar. There’s some behind-the-scenes stuff going on…

    If you use an ivar in your code without self, that’s direct access to the ivar. If you use either [self someIvarName] or self.someIvarName, you’re actually sending a message to the object (which is self). The runtime attempts to resolve this message and will use one of a number of mechanisms: If you have defined a method with a matching name, that method will be used, if no such method (or property) exists, then key-value-coding will use an identically named ivar by default.

    As for the impact, this will differ based on your code. For example if your property is a retained property (as opposed to assigned), there’s a very significant difference between:

    someVar = nil
    

    and

    self.someVar = nil
    

    The synthesized setter will properly release someVar before setting it to nil, whereas in the first example, you’ve now leaked memory. This is just one example of the difference.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just curious. I heard something about the new G1GC addressing that latency problem. I
Just curious about it... Cedric Beust created TestNG and I understand from an interview
i was just curious about webbot project and i wish that i could create
Just curious about jQuery/Javascript and referring to options within variables. So, I wrote a
I'm mostly just curious about this. Do assemblies that would be considered part of
I'm just curious about if letting installed some snippets that are not essentials to
I understand that sets in Python are unordered, but I'm curious about the 'order'
I'm new to drupal and just curious about that what are the steps to
I'm just curious about this. It strikes me that the behavior of a StringBuilder
Just curious about the encodings that system is using when handling string storing(if it

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.