TUTORIAL: NSTableView, Image buttons, automatic sizing, hiding columns

This is a continuation of the tutorial that I did using a random names, addresses, phone numbers, etc. generated on my website (plist format) using php. It is there if you want to use it…

There are a lot of features planned for this project as I continue to document my adventure through Cocoa, etc.

This has some cool auto resizing of the window using simple animation, and even if you are way beyond me in your knowledge and experience, take a peek at this tutorial. It is short, and doesn’t contain a lot of code. Download it and click on the buttons, it is simple animation, but at least in my opinion, it worked out really cool.

I tried using the NSTableViewDataSource protocol in order to have more control over some aspects of the project, and ran into a stumbling block, in that everything worked perfect until I sorted the NSTableView and then I couldn’t figure out a way to keep the row (record) the user clicked on, synchronized with the array controller. I looked everywhere, but eventually I decided to use a different approach that worked really well, with much less code.

I posted a message on this problem, and never did get a solution. I know there’s a way, I just don’t have enough experience at this, and I need to take a break from all this for a few days…

I did a work around using strictly bindings, which for this particular project was not my preferred method, but ended up with a good solution that allows the user to edit the data on a separate panel, and if for some reason they change their mind, the record can be restored correctly. I like this approach, particularly when NSTextView(s) the might contain a lot of text.

The difference between the two approaches is that with the NSTableViewDataSource protocol the user can edit the data via the inputSheet, and if they accept the record, then it is inserted, or added to the NSMutableArray. This method used bindings for the NSTableView, but not for the inputSheet.

Using the Bindings approach required much less code, and as the user added, or modified the data on the inputSheet, you could see the selected NSTableView row (record) being updated. If the user clicked the OK button, nothing further had to be done, but if the clicked on Cancel, then the old Record was restored. There was huge problem I ran into using this method, until I figured out about mutableCOPY, quite by accident.

This is starting to develop as a really nice little application.

Please let me know if you have any suggestions. I am posting the address to my website instead of each individual document, because I am still trying to come up with workable naming conventions for the projects and files, and am still moving things around.

This Project is called :

Generate and Import XML (plist) Data into an NSTableView Object - Part 2

http://www.journey-of-flight.com/

Best Regards,

Bill Hernandez
Plano, Texas