O'Reilly logo
  • Suk Sohn thinks this is interesting:

Lines 38–41 add the sorting category to UIButton. A category is a group of related method implementations that enhance an existing class. Category methods are added to a class at runtime, so we can add methods to UIButton even though we cannot edit the original class declaration and implementation. The sorting category has only one method—compareButtonTitles: (defined in Fig. 5.18), which compares two UIButtons’ titles alphabetically. We use this method to sort an NSMutableArray of UIButtons.


Cover of iPhone® for Programmers: An App-Driven Approach Deitel® Developer Series