diff --git a/objcguide.xml b/objcguide.xml index 6881a4a..ea3185b 100644 --- a/objcguide.xml +++ b/objcguide.xml @@ -4,7 +4,7 @@

-Revision 2.18 +Revision 2.20

@@ -415,6 +415,27 @@ Revision 2.18 + + + There should not be a space between the type identifier and the name + of the protocol encased in angle brackets. + + +

+ This applies to class declarations, instance variables, and method + delcarations. For example: +

+ + @interface MyProtocoledClass : NSObject<NSWindowDelegate> { + @private + id<MyFancyDelegate> delegate_; + } + - (void)setDelegate:(id<MyFancyDelegate>)aDelegate; + @end + + +
+ @@ -586,6 +607,10 @@ Revision 2.18 a different address-space, the method naming isn't quite as important.

+

+ There should be a single space between the class name and the opening + parenthesis of the category. +

@@ -1165,7 +1190,7 @@ Revision 2.18 Do not use the NS_DURING, NS_HANDLER, NS_ENDHANDLER, NS_VALUERETURN and NS_VOIDRETURN macros unless you are writing code that - needs to run on MacOS 10.2 or before. + needs to run on Mac OS X 10.2 or before.

Also be aware when writing Objective-C++ code that stack based objects @@ -1319,8 +1344,8 @@ Revision 2.18

Properties in general are allowed with the following caveat: properties are an Objective-C 2.0 feature which will limit your code to running - on the iPhone and MacOS X 10.5 (Leopard) and higher. Dot notation to - access properties is not allowed. + on the iPhone and Mac OS X 10.5 (Leopard) and higher. Dot notation + is allowed only for access to a declared @property. @@ -1446,39 +1471,20 @@ Revision 2.18

- We do not allow the use of dot notation to access properties for - the following reasons: + Dot notation is idiomatic style for Objective-C 2.0. It may be used + when doing simple operations to get and set a @property + of an object, but should not be used to invoke other object behavior.

-
    -
  1. - Dot notation is purely syntactic sugar for standard method calls, - whose readability gains are debatable. It just gives you another - way to make method calls. -
  2. -
  3. - It obscures the type that you are dereferencing. When one sees: - [foo setBar:1] it is immediately clear that you are - working with an Objective-C object. When one sees - foo.bar = 1 it is not clear if foo is an object, or - a struct/union/C++ class. -
  4. -
  5. - It allows you to do method calls that look like getters. - - NSString *upperCase = @"foo".uppercaseString; - - which is not only confusing, but difficult to spot in a code review. -
  6. -
  7. - It hides method calls. - - bar.value += 10; - - is actually two separate method calls (one to set and one to get) - and if your properties are not simple you may find a lot of work - being done in a hidden manner. -
  8. -
+ + NSString *oldName = myObject.name; + myObject.name = @"Alice"; + + + NSArray *array = [[NSArray arrayWithObject:@"hello"] retain]; + + NSUInteger numberOfItems = array.count; // not a property + array.release; // not a property +
@@ -1550,7 +1556,7 @@ Revision 2.18

-Revision 2.18 +Revision 2.20