• 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: Do I need private accessor methods?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Do I need private accessor methods?


  • Subject: Re: Do I need private accessor methods?
  • From: Ryan Britton <email@hidden>
  • Date: Fri, 28 Apr 2006 15:15:18 -0700

They are very useful for ensuring your code is threadsafe. For this reason alone I recommend using them. Take a look at the following link to solve your last concern:

http://www.kevincallahan.org/software/accessorizer.html


On Apr 28, 2006, at 2:32 PM, Eric Lin wrote:

Do I need to create private accessor methods for my private instance
variables? I'm asking this because the most correct constructure form seems
to require it:


   if (self = [super init]) {
         [self setPrivateVariable:123];
   }

This wouldn't be correct in the case that [super init] returns a different
self:


   if (self = [super init]) {
         privateVariable = 123;
   }

If I indeed have to do it the first way, how do I create private accessor
methods? And should I make it a rule of thumb to create accessor methods
for all private variables? (would seem like quite a chore though).


Thanks,
Eric
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Do I need private accessor methods?
      • From: Chris Hanson <email@hidden>
    • Re: Do I need private accessor methods?
      • From: "Shawn Erickson" <email@hidden>
References: 
 >Do I need private accessor methods? (From: "Eric Lin" <email@hidden>)

  • Prev by Date: CGLayer and cached views
  • Next by Date: -isFlipped not working right when drawing IconAndTextCell to NSImage
  • Previous by thread: Do I need private accessor methods?
  • Next by thread: Re: Do I need private accessor methods?
  • Index(es):
    • Date
    • Thread