Jimmy
Jimmy

Reputation: 1104

Space used in Objective-C method (coding style),which is more preferable?

I found three kind of coding style when writing method declaration and implementation

  1. -(id)delegate;

  2. - (id)delegate;

  3. - (id) delegate;

The first is really rare.

Sice I am a IOS developer , I found the second one is the most in UIKit and most code i found online is in this style.

My colleague told me that the third one is very common in Mac OS X

Personally, I prefer the second type. I'm just wondering is there any coding convention about this question?

Upvotes: 0

Views: 392

Answers (2)

Black Frog
Black Frog

Reputation: 11703

You can use whatever style you like for your own code. If you join an open source project, you will use the style set forth in that project. The main goal is to be consistent in your style. Me personally follows Google Objective-C Style Guide.

Upvotes: 0

Jhaliya - Praveen Sharma
Jhaliya - Praveen Sharma

Reputation: 31722

Here is apple documented coding guidelines, which uses style #2 (space after -)

http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CodingGuidelines/CodingGuidelines.html

There are two blog tutorial with examples ..

http://cocoadevcentral.com/articles/000082.php

http://cocoadevcentral.com/articles/000083.php

Upvotes: 3

Related Questions