PDA

View Full Version : Finding the right resources...




Tylox
Mar 20, 2008, 03:33 PM
Howdy,

I am currently working my way through the Hillegass book and just finished the second challenge to Chapter 6, sorting a NSTableView without using Bindings or the NSController class.

After spending approximately 2 evenings digging through the class reference documents at Apple, I narrowed down my search to one of three documents for the code I needed to implement:

NSSortDescriptor (http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSSortDescriptor_Class/Reference/Reference.html)

Creating and Using Sort Descriptors (http://developer.apple.com/documentation/Cocoa/Conceptual/SortDescriptors/Concepts/Creating.html#//apple_ref/doc/uid/20001845-BAJEAIEE)

NSTableDataSource Protocol Reference (http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Protocols/NSTableDataSource_Protocol/Reference/Reference.html#//apple_ref/occ/instm/NSObject/tableView:sortDescriptorsDidChange:)

This is where I got stuck. I understood that I somehow needed to implement sortDescriptors; however, since the class documentation only tends to list the method and a brief summary of what it does, I did not grasp how to connect sortDescriptors to my TableView.

After getting frustrated with the Apple documentation, I started googling around for similar example code. I originally avoided this approach as I didn't want to accidently come across the answer. I wanted to figure out the logic behind the code I needed to insert...

I found out the answer was, quite simply, to drop the following method in the myDocument class:

- (void)tableView:(NSTableView *)aTableView sortDescriptorsDidChange:(NSArray *)oldDescriptors

Now of course, as I am now writing this the day after the exersize, I realized WHY this works...delegates! (I should have realized this right away with the "...DidChange" syntax, but I'm still pretty new to this).

My question is...I feel if the Apple documentation contained more details in their descriptions or links example code showing how to implement said code, I would have solved this puzzle much earlier. Is this mainly because I am still new to Cocoa programming, while an advanced programmer would instantly see that method and know exactly how to implement it? If not, what are some suggestions for further resources to learn this information?

Thanks for your help!



HiRez
Mar 20, 2008, 03:44 PM
Oops, didn't see you found the more detailed docs...please delete this post.

MacsAttack
Mar 20, 2008, 04:31 PM
May want to check out this site

http://cocoacast.com/

The podcasts work through the Hillegass book. May have some illuminating info.