I could not work out how to do this, and in fact posted a long reply (now deleted…) explaining that it couldn’t be done, and that personName.length could not work.
But now I see it does work, but I 'd like to know how. My understanding is as follows:
Each row corresponds to an object in the NSMutableArray instance employees. A column corresponds to one of the components of the object, in this case personName.
To make the column sortable, we specify a ‘key’ to be used in comparing two objects. This key is the name of one of the components. In this case we make the obvious choice of personName when the Name column title is clicked.
We must also specify a method to be used to do the actual compare. personName is an NSString, and compare is an NSString method, so that works.
But the length method of NSString returns just an unsigned integer, which doesn’t have any methods, so how does compare work with length, as it certainly does??!!