Objective-C convenient manners
I spent some time with Objective-C and I see it's something like religious for some开发者_开发技巧 (especially experienced) programmers. I like it and I would like to catch good manners. Can you tell me where can I find these holy rules?
For example I'm confused of naming constants, or keys. Should it be kName
or nameKey
or NameKey
?
Or...
I noticed some ivars are declared with _ or __... I want to do clear code. Thanks!
Check these articles about Cocoa and Objective-C style and conventions:
http://cocoadevcentral.com/articles/000082.php
http://cocoadevcentral.com/articles/000083.php
http://cocoawithlove.com/2009/06/method-names-in-objective-c.html
The Coding Guidelines for Cocoa in Apple's Mac OS X Reference Library are a good place to start.
Consistency is the best rule you can ever apply.
Either pick a style you like and stick with it, or if you're working on an existing code base it's good practice to adopt the rules that have already been applied.
精彩评论