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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:57:36+00:00 2026-06-02T06:57:36+00:00

In Objective-C, we can add @property and @synthesize to create a property — like

  • 0

In Objective-C, we can add @property and @synthesize to create a property — like an instance variable with getter and setter which are public to the users of this class.

In this case, isn’t it just the same as declaring an instance variable and making it public? Then there won’t be the overhead of calling the getter and setter as methods. There might be a chance that we might put in validation for the setter, such as limiting a number to be between 0 and 100, but other than that, won’t a public instance variable just achieve the same thing, and faster?

  • 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-02T06:57:37+00:00Added an answer on June 2, 2026 at 6:57 am

    Even if you’re only using the accessors generated by @synthesize, they get you several benefits:

    1. Memory management: generated setters retain the new value for a (retain) property. If you try to access an object ivar directly from outside the class, you don’t know whether the class might retain it. (This is less of an issue under ARC, but still important.)

    2. Threadsafe access: generated accessors are atomic by default, so you don’t have to worry about race conditions accessing the property from multiple threads.

    3. Key-Value Coding & Observation: KVC provides convenient access to your properties in various scenarios. You can use KVC when setting up predicates (say, for filtering a collection of your objects), or use key paths for getting at properties in collections (say, a dictionary containing objects of your class). KVO lets other parts of your program automatically respond to changes in a property’s value — this is used a lot with Cocoa Bindings on the Mac, where you can have a control bound to the value of a property, and also used in Core Data on both platforms.

    In addition to all this, properties provide encapsulation. Other objects (clients) using an instance of your class don’t have to know whether you’re using the generated accessors — you can create your own accessors that do other useful stuff without client code needing changes. At some point, you may decide your class needs to react to an externally made change to one of its ivars: if you’re using accessors already, you only need to change them, rather than make your clients start using them. Or Apple can improve the generated accessors with better performance or new features in a future OS version, and neither the rest of your class’ code nor its clients need changes.

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

Sidebar

Related Questions

In Objective-C I can create categories to extend a class. I can also add
Objective-C has directives like: @interface @implementation @end @protocol @property @synthesize I think of these
In some languages like C# and Objective C, you can create class extensions. That
How can I add additional, custom information to my objective-c methods and properties? I
With Objective-C, you can add iVars/properties to a class using the associated object support
So, I understand that Categories in Objective-C can be used to add methods to
(programming in iPhone objective-C) I have a class level NSString* that I create, add
I've just discovered, via the Objective Flickr API, that you can add projects into
in Objective-C if I need to add additional method to UIButton I can use
I am porting cpp code into Objective C. In cpp we can add a

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.