On Apr 27, 2009, at 4:42 PM, Adam R. Maxwell wrote:

On Apr 27, 2009, at 2:10 AM, WT wrote:

On Apr 25, 2009, at 6:47 PM, David Scheidt wrote:

I've got a sub-class of NSTableView. I have windows that have more than one instance of this TableView in them, which need to behave slightly differently, based on which one they are.

The way I understood his question, this is a problem of *identifying* instances. At some point or points in his code, he's got a pointer to an instance of his subclass of NSTableView and needs to be able to determine which of several instances that is. I still maintain that if these instances have different tag values then

My understanding wants to do this from a tableview subclass, though:

switch([self tag]) {
        case 1:
                return ...
        case 2:
                return ...
}

...so the tag is truly being used as a container for a property, which it doesn't sound like you intended? I don't think using tags from a controller class is a bad solution, although my own preference would be to have something like Jon/Mike/Jim suggested. Using the tag from the tableview subclass seems like a poor design, IMO, and not easy to maintain or extend.

Of course the tag is a container for *a*/*one* property, the tag itself, but it's not a container for multiple properties, as others had interpreted it.

Regardless, your switch statement is returning what, exactly? If it's returning the pointers to the various NSTableView subclass instances then, yes, of course the tag solution is a poor design because, in that case, the OP already had pointers to the instances and he might as well just use pointer comparison to identify the table he's been handed at that point, as suggested by Dave deLong here: <http://lists.apple.com/archives/cocoa-dev/2009/Apr/msg01803.html >.

But let me quote the OP's reply to Dave:

On Apr 25, 2009, at 11:14 AM, David Scheidt wrote:

I'm using bindings, so I don't have have any data source methods. Sorry, should have said that. It's Core Data, cocoa bindings, 10.5+ only.

Now, I'll fully admit not having any experience whatsoever with Core Data and minimal experience with bindings, so I may be totally wrong in what I'm about to say, but the OP's response solidified my impression from his first post that he does NOT have pointers to the various table instances, in which case his question of how to identify them makes perfect sense. In that case, I still maintain that the tags solution is simple, effective, and maintainable.

Perhaps it's time the OP clarified what exactly he had in mind.

Wagner
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to