No 1 in (serious) series of coding style…
No 1 in (serious) series of coding style posts: Private methods
Declaring private methods in a class extension (like an anonymous category) rather than a named category makes the compiler warn you when those methods aren’t implemented.
# MyClass.h @interface MyClass : NSObject { } - (void)publicMethod; @end # MyClass.m #include "MyClass.h" @interface MyClass () - (void)privateMethod; @end @implementation MyClass - (void)publicMethod; { NSLog(@"public"); } - (void)privateMethod; { NSLog(@"very private"); } @end
Gernot 12:55 on 20. July 2010 Permalink
Also: With the new Runtime, you can declare private ivars in a class extension. The new Runtime is available on the iPhone since 3.0 (might be 3.1 I’m not sure now) and on the Simulator of XCode 4.