• 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: Name instance variables, methods and parameters.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Name instance variables, methods and parameters.


  • Subject: Re: Name instance variables, methods and parameters.
  • From: Daryn <email@hidden>
  • Date: Tue, 27 Jan 2004 23:55:01 -0600

Apple warns not to use underscores because they reserve them for use
within the frameworks. Refusing to obey this requirement will cause
trouble if/when one of your framework subclasses stomps over the
framework's private method or ivar.

For private ivars, just use @private in the interface and give them a
unique prefix like my_ if you don't want to collide with method args.
For private methods, just don't add them to the interface or use a
<MyObject>Private category, perhaps in the source file rather than the
header if you really don't want people to see them.

On Jan 27, 2004, at 9:00 PM, Czarny, Eric wrote:

> I know that this may be an awfully common question, but I haven't
> found a
> single answer, nor a collection of answers, to give me a better idea.
> The
> section on coding style within Apple's developer documentation states
> that
> an underscore should not be used for naming private methods and
> instance
> variables. I know I have seen this topic being discussed at CocoaDev,
> but
> couldn't gather sufficient information. I'd like to continue to use an
> underscore, but if it goes against Apple's own wishes, I'd like avoid
> it if
> I could.
>
> The major problem I have is if I just use an unmodified instance
> variable,
> such as:
>
> NSString *data;
>
> instead of:
>
> NSString *_data;
>
> Which I like better, but conflicts with:
>
> - (id)parseData: (NSData *)data;
>
> I've seen people just use a single character as the name for the
> parameter
> name, but I feel it makes for less readable code.
>
> I suppose it's all a matter of personal preference, but I'd like some
> input
> from more experienced developers.
>
> Thanks!
> Eric Czarny
> _______________________________________________
> cocoa-dev mailing list | email@hidden
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
> Do not post admin requests to the list. They will be ignored.

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Name instance variables, methods and parameters.
      • From: Raphael Sebbe <email@hidden>
    • Re: Name instance variables, methods and parameters.
      • From: Allan Odgaard <email@hidden>
References: 
 >Name instance variables, methods and parameters. (From: "Czarny, Eric" <email@hidden>)

  • Prev by Date: Re: Name instance variables, methods and parameters.
  • Next by Date: Doe each NSTableView requires its own controller?
  • Previous by thread: Name instance variables, methods and parameters.
  • Next by thread: Re: Name instance variables, methods and parameters.
  • Index(es):
    • Date
    • Thread