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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:28:10+00:00 2026-06-03T04:28:10+00:00

Possible Duplicate: difference between accessing a property via “propertyname” versus “self.propertyname” in objective-c? In

  • 0

Possible Duplicate:
difference between accessing a property via “propertyname” versus “self.propertyname” in objective-c?

In my class, i am not sure whether to use self.property of property, such as

  dateFormatter = [[NSDateFormatter alloc] init];
  //or
  self.dateFormatter = [[NSDateFormatter alloc] init];

They both seem to work fine. Are there any differences between these two usage? I am confused.

  • 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-06-03T04:28:12+00:00Added an answer on June 3, 2026 at 4:28 am

    property is inface your methods getter and setter, when ever you call it via self.dateformator, it will call the property if you have synthesized the object and self generated getter and setter naming(setProperty and getProperty),

    in your case, your first line is not the propery, you are accessing directly the iVar of your class while in 2nd line of your code you are using the property getter and setter methods,

    now your question what is the difference,

    the difference is that in iVar access(your first line), you will have to manually release the object and will have the retain count of 1 increased, and memory allocted will be accociated to it. while in self.property, a memory is allocated, but a new block will be assign to the variable as apple property management do this. but the retain count will be again the same.

    so a block of memory will be lost.

    Now i would like to tell some thing beneficial that is the good approach is to use properties for object, because if you have written retain in the property attributes in interface file, then your memory management will be at the compileres end, but remember to write release in dealloc method. and for code lines that you have writter here, like

    self.someProperty = [[NSArray alloc] init];
    

    use it as

    NSArray* arr = [[NSArray alloc] init];
     self.someProperty = arr;
     [arr release];
    

    now your retain count will be same as you want that of one, and don’d care of where to release this, it will auto release in dealloc method if you writtern it.

    and for the one you write earlier, you will have to keep track that where you have to release the object

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

Sidebar

Related Questions

Possible Duplicate: What the difference between “$@” and “$*” in bash? For years and
Possible Duplicate: What is the difference between String.Empty and “” Is equivalent to String.Empty
Possible Duplicate: Difference between “var” and “object” in C# I would like to know
Possible Duplicate: Difference between Property and Field in C# public class Test { public
Possible Duplicate: Difference in SQL Between operator and “>=” & “<=” operator I see
Possible Duplicate: What’s the difference between “Array()” and “[]” while declaring a JavaScript array?
Possible Duplicate: Difference between using var and not using var in JavaScript For the
Possible Duplicate: Difference between using var and not using var in JavaScript Hello, I
Possible Duplicate: Difference between using var and not using var in JavaScript var foo
Possible Duplicate: Difference between Category and Class Extension? I am often told that when

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.