Categories are a cool feature of Objective-C that allow you to extend existing classes with extra methods. This helps you to write really clean code by adding utility methods directly to the classes they relate to, so they can be called in a natural, object-oriented way.
A typical example of a category method is given below. Here we add an isNumeric method to NSString:
While scanning a few code examples inside the iPhone SDK, I bumped into something interesting. I wrote a short example to mimic what I found…take a look at the following interface declaration:
@interface SomeClass : NSObject
@property (nonatomic, retain) NSString *str;
@property (nonatomic, retain) NSDate *date;
@property (readonly) NSString *testSomething;
The only aspect that should standout is the property declaration for testSomething . Notice there is no instance instance variable tied to this declaration. This is different if for no reason other than the typical use for properties is as a shorthand for declaring accessor methods for instance variables.