• 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: Is there a warning for this?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is there a warning for this?


  • Subject: Re: Is there a warning for this?
  • From: Izidor Jerebic <email@hidden>
  • Date: Tue, 29 Dec 2009 09:49:20 +0100


Well, the documentation says <http://gemma.apple.com/mac/library/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingBasics.html >:


Avoid the use of the underscore character as a prefix meaning private, especially in methods. Apple reserves the use of this convention

Note the "especially", and also note the existence of many underscored instance variables in appkit and foundation.


I understand it as direction to avoid underscore in *any* name, not just method name.

It is true that instance variables are not as critical as methods. If you subclass appkit class and use underscored instance variable which clashes with superclass, compiler will warn you and your code won't compile, so no real damage will occur, as opposed to clashing private method where your program will happily compile and then sometimes crash at runtime. The only problem can be if future framework class adds instance variable which clashes with yours, thus making your existing code un-compilable. So using underscored instance variables is not dangerous, but it is asking for trouble, and why would you want that?

izidor



On 29.12.2009, at 6:36, Sean McBride wrote:

Kyle Sluder (email@hidden) on 2009-12-24 9:20 AM said:

Otherwise, give your ivars a prefix (underscore is
verboten according to Apple, since they use it in the frameworks).

This is a common misconception. The underscore is reserved by Apple for
method names, not ivars. That's how they can safely add new methods to
public classes without conflicting with our subclasses.


I'd suggest you _do_ use underscore as your ivar prefix.

See also:
<http://gemma.apple.com/mac/library/documentation/Cocoa/Conceptual/
CodingGuidelines/Articles/NamingIvarsAndTypes.html>

<http://lists.apple.com/archives/Cocoa-dev/2009/Jan/msg00608.html>

Sean

--
"Terrorism is the war of the poor, and war is terrorism of the rich" -
Sir Peter Ustinov

_______________________________________________

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

_______________________________________________

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


References: 
 >Is there a warning for this? (From: Brian Bruinewoud <email@hidden>)
 >Re: Is there a warning for this? (From: Kyle Sluder <email@hidden>)
 >Re: Is there a warning for this? (From: "Sean McBride" <email@hidden>)

  • Prev by Date: Re: Updating tracking areas Rect
  • Next by Date: launching my application at startup(whenever pc starts)
  • Previous by thread: Re: Is there a warning for this?
  • Next by thread: Adding sub menus programatically
  • Index(es):
    • Date
    • Thread