Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > understanding a subclass of NSTableView

understanding a subclass of NSTableView
Thread Tools
Fresh-Faced Recruit
Join Date: Dec 2002
Status: Offline
Reply With Quote
Aug 27, 2003, 01:39 AM
 
I was trying to figure out how to create a TableView similar to that of iTunes and I found
something at Apple's developer site:

http://developer.apple.com/samplecod...MP3_Player.htm

They just actually override one method and calling an instance method.

I'm having a bit of difficulty on what needs to be done in subclassing the NSTableView.

Their code doesn't declare the tableView outlet as an instance of the subclass of the NSTableView but rather as the IBOutlet id.

I guess what I don't understand is how does it know to use this subclass as opposed to the parent NSTableView class.

I also don't quite understand why they made the controller object as an outlet for the tableView.

I'd appreciate any clarifications on this...

Thanks...
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Aug 27, 2003, 02:33 AM
 
Originally posted by macaroni:
Their code doesn't declare the tableView outlet as an instance of the subclass of the NSTableView but rather as the IBOutlet id.

I guess what I don't understand is how does it know to use this subclass as opposed to the parent NSTableView class.
It doesn't matter what type of variable you use to refer to an object; they are all ids when it comes down to it (with id being defined as a pointer to an object). You could conceivably use an NSWindow pointer to refer to it, though that would be really silly. The class of an object is an inherent property of the object. It is a subclass of NSTableView because the object in the nib is an instance of that subclass.
That's one of the most important things to learn about Objective-C -- you do not directly have objects as variables. You just reference them with pointers. You can have five different pointers all pointing to the same instance of a class. Most importantly, you can have the pointers all be ids, and not have any idea what kind of object it actually is as long as you know what methods it will respond to. This is how protocols and the responder chain work.

I also don't quite understand why they made the controller object as an outlet for the tableView.
Because with the interface they're using, it queries the controller (which keeps track of the song listing) to find out what song it should play when you click on a row.
Honestly, I think their division of duties for the two classes is a bit silly -- the table view basically asks the controller which of its rows selected, and then proceeds to play the song itself.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:20 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2