Objective C - Classes - Categories
Want to add custom behavior to a class, but
- Don't have its source, or
- Want some other pre-written classes to automatically inherit new behavior
Subclassing won't satisfy (2). Can't tweak the implementation because of (1). Solution: Categorize the class.
- Works independently of having categorized class's source
- Adds and replaces methods in the categorized class
- Cannot access replaced methods
- Changes are inherited by all pre-existing subclasses