From 7e59842bf4de53c7bfed94c3430bf5fd2a8f30f4 Mon Sep 17 00:00:00 2001 From: Lukasz Warchol Date: Tue, 13 Jan 2015 22:53:41 +0100 Subject: [PATCH] Add rule for creating categories extensions. --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index 5aafee6..ceaf112 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ Here are some of the documents from Apple that informed the style guide. If some * [Comments](#comments) * [Naming](#naming) * [Underscores](#underscores) + * [Categories](#categories) * [Methods](#methods) * [Variables](#variables) * [Property Attributes](#property-attributes) @@ -228,6 +229,30 @@ An exception to this: inside initializers, the backing instance variable (i.e. _ Local variables should not contain underscores. +### Categories + +When creating a category on class maintened by third party developer always use three letter prefix in methods names. This way it will not conflict with current or future implementations. + +**Preferred:** + +```objc +@interface NSArray (RWTExtension) + +- (id)rwt_firstObject; + +@end +``` + +**Not Preferred:** + +```objc +@interface NSArray (Extension) + +- (id)firstObject; + +@end +``` + ## Methods In method signatures, there should be a space after the method type (-/+ symbol). There should be a space between the method segments (matching Apple's style). Always include a keyword and be descriptive with the word before the argument which describes the argument.