One Quickie

Sorting with Selectors (NSObject->General)
You can sort mutable arrays by providing a selector that is invoked on each of the elements of the array. I always get confused about NSOrderedAscending / NSOrderedDescending (I think they're actually backwards, but that's just me). Here it is in a nutcase: Given this sort command:
    [themStitches sortUsingSelector: @selector(compareByRowLocation:)];
And this selector on the BWCrossStitch class:
  - (NSComparisonResult) compareByRowLocation: (BWCrossStitch *) thing2;
Figure out which is lesser or greater, and return one of these. Note that self is the object's logical value, not the actual value of the self pointer.

borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book