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

Do I need private accessor methods?


  • Subject: Do I need private accessor methods?
  • From: "Eric Lin" <email@hidden>
  • Date: Fri, 28 Apr 2006 14:32:00 -0700

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


  • Follow-Ups:
    • Re: Do I need private accessor methods?
      • From: "John C. Daub" <email@hidden>
    • Re: Do I need private accessor methods?
      • From: Nir Soffer <email@hidden>
    • Re: Do I need private accessor methods?
      • From: Ryan Britton <email@hidden>
  • Prev by Date: Re: Correct Time to Write Extra code on Shutdown
  • Next by Date: Re: Conditionally enable a button based on NSArrayController's selectedObjects?
  • Previous by thread: Re: Correct Time to Write Extra code on Shutdown
  • Next by thread: Re: Do I need private accessor methods?
  • Index(es):
    • Date
    • Thread