Chp 6 Challenge 1 Solution
Monday, November 07, 2005
This one is really quite simple. As the hint shows, there is a length method that you can use. As you have read about KeyPaths, one page before the Challenge 1 is made key paths are accessed using a period. So to answer this challenge after you've completed the excercises, go to the MyDocument.nib in Interface Builder.
Select the first column of your table, then go to the attributes of the column to view the the sort key field. Enter "personName.length" as the sort key. Now set the Sort Selector to "compare:". Save the nib file, compile the project and run.
Now clicking the column header for person name will sort based on the length of the person's name, rather than alphabetical order.
Select the first column of your table, then go to the attributes of the column to view the the sort key field. Enter "personName.length" as the sort key. Now set the Sort Selector to "compare:". Save the nib file, compile the project and run.
Now clicking the column header for person name will sort based on the length of the person's name, rather than alphabetical order.
Comments:
<< Home
Setting personName.length isn't sufficient. You also need to change the Sort Selector back to compare: (from caseInsensitiveCompare:). You'll get an exception otherwise...
2006-06-05 14:53:42.043 RaiseMan[2630] *** -[NSCFNumber caseInsensitiveCompare:]: selector not recognized [self = 0x327f60]
Post a Comment
2006-06-05 14:53:42.043 RaiseMan[2630] *** -[NSCFNumber caseInsensitiveCompare:]: selector not recognized [self = 0x327f60]
<< Home