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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:35:38+00:00 2026-05-24T02:35:38+00:00

Possible Duplicate: Difference between calling self.var vs var Edit : actually, i did not

  • 0

Possible Duplicate:
Difference between calling self.var vs var

Edit : actually, i did not understand that to add an object to an array does not require a “setter”, but actually a “getter”, so the use of “self” was not important.

can you tell me why here in this code we use sometimes “self.” and sometimes we don’t : if we have a “message” to send to the property, we usually use “self.”, but here in the locationManager delegate for exemple, we don’t use it :

- (void)viewDidLoad {
    self.locationMeasurements = [NSMutableArray array];
}

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
    [locationMeasurements addObject:newLocation];

- (void)viewDidUnload {
    locationDetailViewController = nil;
}


- (void)reset {
    [self.locationMeasurements removeAllObjects];
}

Thanks for your help

Paul

  • 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-24T02:35:39+00:00Added an answer on May 24, 2026 at 2:35 am

    when you use self you pass through the accessor methods, thereby exploiting the property attributes such as non atomic (or atomic) when reading, or copy, retain,assign when assigning.

    When you do not use self you access the variable directly.

    Example:

    @interface X : NSObject
    {
        NSObject * anObject;
    }
    @property(nonatomic,retain) NSObject * anObject;
    
    self.anObject = [[NSObject alloc]init]autorelease];
    

    will retain the object in the property

    anobject = [[NSObject alloc]init]autorelease];
    

    will NOT retain it, the object will be released later on.

    self. is syntactic sugar for:

    -(NSObject *)anObject;
    
    and
    
    -(void)setAnObject:(NSObject *)other;
    

    the attributes in your property declaration define how those methods are implemented behind the scenes

    In your example code in viewDidLoad the self. is probably needed to make sure the array is retained after assigning. However in “reset” it is probably not needed as you just manipulate the object itself and not the assignment to the property (unless you deal with multithreading and atomic accessors).

    One thing to note is that if you create something in ViewDidLoad (the MutableArray) you should destroy it in viewDidUnload ( self.locationMeasurements = nil; )

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

Sidebar

Related Questions

Possible Duplicate: Difference between using var and not using var in JavaScript var foo
Possible Duplicate: Difference between using var and not using var in JavaScript Hello, I
Possible Duplicate: Difference between “var” and “object” in C# I would like to know
Possible Duplicate: Difference between using var and not using var in JavaScript What is
Possible Duplicate: Difference between using var and not using var in JavaScript Hi All
Possible Duplicate: What is the difference between app.config file and XYZ.settings file? I'm not
Possible Duplicate: difference between string object and string literal When initializing a String object
Possible Duplicate: Difference between class property mVar and instance variable self.mVar I am new
Possible Duplicate: C#: Difference between List<T> and Collection<T> (CA1002, Do not expose generic lists)
Possible Duplicate: Difference between Covariance & Contra-variance I'm trying to understand what covariance and

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.