• 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
Re: Instance variables: access directly vs. getter / setter
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Instance variables: access directly vs. getter / setter


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

Am 09.10.2009 um 11:30 schrieb Graham Cox:

In init and dealloc, it is usual & recommended to access the ivar directly - not because self isn't defined (it is), but because at those times you are usually only concerned with setting the ivar's initial value (possibly to an object), or releasing it, without side effects.

Graham,

thanks a lot for clarifying and I stand corrected in concerns of the "self" definition: Don't know what crossed my mind, how should "init" return the "self"-pointer without it being defined. So I'll change my code to use accessors, although

    [self setIvar:[self ivar] + 1];

instead of

    iVar++;

looks a bit confusing to me. I read that

    self.iVar++;

is also supported, but I just don't like the dot-syntax. At least not yet ...

Thanks again, 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>
References: 
 >Instance variables: access directly vs. getter / setter (From: Matthias Arndt <email@hidden>)
 >Re: Instance variables: access directly vs. getter / setter (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Updating application info plist
  • Next by Date: Re: Instance variables: access directly vs. getter / setter
  • Previous by thread: Re: Instance variables: access directly vs. getter / setter
  • Next by thread: Re: Instance variables: access directly vs. getter / setter
  • Index(es):
    • Date
    • Thread