• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Instance variables: access directly vs. getter / setter
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Instance variables: access directly vs. getter / setter


  • Subject: Instance variables: access directly vs. getter / setter
  • From: Matthias Arndt <email@hidden>
  • Date: Fri, 9 Oct 2009 11:01:52 +0200

While restructuring some old classes I'm uncertain about the preferred way to access instance variables within their own instance:

I tend to defines all these variables as properties and use their implicit getters / setters, but ...

1. ) ... in the designated initializer I have to access the instance variables directly, because at this moment "self" is not yet defined, is it?

2.) ... are there significant performance issues or other reasons to prefer the direct reference to (or direct assignment of) instance variables? At least the code of the setters / getters might impact the performance, but I'd sacrifice it for the sake of a consistent code.

Any comments / suggestions?

Matthias
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Instance variables: access directly vs. getter / setter
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: How to set checkbox state in TableView columnheader
  • Next by Date: Re: Instance variables: access directly vs. getter / setter
  • Previous by thread: re: [iPhone} Exception After Creating First Object
  • Next by thread: Re: Instance variables: access directly vs. getter / setter
  • Index(es):
    • Date
    • Thread