Re: folder content as model for NSTableView
Re: folder content as model for NSTableView
- Subject: Re: folder content as model for NSTableView
- From: j o a r <email@hidden>
- Date: Fri, 15 Feb 2008 15:10:35 -0800
On Feb 15, 2008, at 2:53 PM, Torsten Curdt wrote:
I wouldn't subclass these classes for that purpose. Create a class
that represents a folder at a given path and give the instances of
that class a "contents" property, then bind that property to the
array controller of your table view.
Hm... but the controller is for NSArray's only ...and the class that
represents the folder is no NSArray. Or did you mean to subclass
NSArray?
You're much too quick to suggest creating subclasses of the system
provided classes - That's not how it's typically done in Cocoa, and
that's one way where Cocoa differs from many other OOP environments
(.NET, et.c.). There are only a handful of classes that you would
typically subclass from: NSObject, NSWindowController, NSView, et.c.
You'll learn more about this as you go along.
What I meant was that the contents of your folder would be a
collection of file system items that could be presented as an array.
Something like this:
@interface TCFileSystemItem : NSObject
{
@private
NSString *_path;
}
- (id) initWithPath:(NSString *) path;
- (NSString *) name;
- (NSImage *) icon;
@end
@interface TCFolder : TCFileSystemItem
{
@private
NSArray *_contents;
}
- (NSArray *) contents;
@end
At this point, if you construct the appropriate TCFolder objects, you
can bind the array controller that serves your table view to the
"contents" property of the folder.
j o a r
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden