• 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: Code style (was: Notify With Parameters)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Code style (was: Notify With Parameters)


  • Subject: Re: Code style (was: Notify With Parameters)
  • From: Conrad Shultz <email@hidden>
  • Date: Thu, 02 Jun 2011 01:17:37 -0700

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 6/1/11 11:45 PM, Bing Li wrote:
> Dear all,
>
> I have a question on delegate/notification techniques in Cocoa.

Roland and Jens have already addressed your main issue (you can also
look at my response to Dan Hopwood a few days ago on a related issue).

But additionally you really should try to adhere to Cocoa coding
conventions
(http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CodingGuidelines/CodingGuidelines.html).

In particular you want to avoid starting method names with capital
letters (unless they begin with a permitted abbreviation or acronym,
such as is the case with, e.g., many NSURL methods).

Also, while not explicitly addressed in Apple's guidelines (AFAICT),
Google's Objective-C style guide
(http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml)
directs that spaces in method declarations be minimized.  For example:

- - (void) setUpNotification: (NSString *) notification withSelector:
(SEL) methodName

would be rewritten:

- - (void)setUpNotification:(NSString *)notification
withSelector:(SEL)methodName

This makes it moderately easier to discern what the actual method
arguments (and their types) are.  While one could certainly say that
Google's guidelines are "unofficial" with respect to this issue, they
comport with Apple's own header style and I believe can be treated as
authoritative in this case.

Not only will following the guidelines now make it easier to share code
and design APIs for use by others in the future, but it will probably
make debugging easier (if for no other reason than people on this list
will have to spend a couple fewer mental run loop cycles decoding what
you intended).

Just some friendly advice from someone who not that long ago was new to
Objective-C and Cocoa and had to go through the same growing pains.

- --
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3nRyEACgkQaOlrz5+0JdXN9ACdHqlhS6EHBCB3sEWpVo/y5WTp
2ZMAnjQTxZi7T+c1PytprpdxbUb4Mwf5
=Mism
-----END PGP SIGNATURE-----
_______________________________________________

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: Code style (was: Notify With Parameters)
      • From: Jens Alfke <email@hidden>
    • Re: Code style (was: Notify With Parameters)
      • From: Jeffrey Walton <email@hidden>
References: 
 >Notify With Parameters (From: Bing Li <email@hidden>)

  • Prev by Date: Re: Declaring and initialization of C array.
  • Next by Date: NSInputStream created from NSData - expected it to close at end of data, did not happen
  • Previous by thread: Re: Notify With Parameters
  • Next by thread: Re: Code style (was: Notify With Parameters)
  • Index(es):
    • Date
    • Thread