Re: Adding my own Properties for Objects
Re: Adding my own Properties for Objects
- Subject: Re: Adding my own Properties for Objects
- From: Mark Munz <email@hidden>
- Date: Thu, 15 Jan 2004 10:24:38 -0700
I don't think it's Model data I'm trying to attach (but I could be
wrong).
An example of what I'm trying to do:
I have a toolbar that I create by loading a dictionary file. It
contains label, icon, etc. + it has some additional tags: type of
action I want to take. Some of the items have different labels, but
the same action-type. All of them share a common Action selector.
Normally, when the action selector gets called. It checks the
Identifier name of the item and then performs the action based on that.
Instead, I just want to look at the action-type data I put with the
item and perform my action based on that piece of information.
If tags were strings (which have greater flexibility in terms of what
could be stored), I probably would have used that. Maybe that's not the
right way to do it (I'm still learning all the Cocoa ins and outs).
Perhaps my over-general request would break the MVC paradigm.
I guess that's why I asked. :-)
Mark
On Jan 15, 2004, at 8:45 AM, Shawn Erickson wrote:
On Jan 14, 2004, at 6:36 PM, Mark Munz wrote:
To anyone that can help:
Is there a way to store a collection of Objects (in a Dictionary) in
any NSView or maybe an NSToolbarItem w/o having to subclass the
object specifically?
I'm looking for something similar to Properties under Carbon that can
be attached to Controls or Windows. Any control or Window can have
"properties" attached to them, making it easy to store additional
data without special handling.
Is this something that's already possible in Cocoa and I'm missing
it? Or am I asking for new functionality?
It sounds like you are attempting to attach model data directly to
view elements. That generally goes against the grain when using Cocoa
(Cocoa generally follows the MVC design pattern).
What are the "properties" that you are attempting to store and what
are they used for?
You could consider using an NSDictionary with the view element as the
key (I think that will work) and the value as the collection of your
"properties". However it is best to have a controller manage such
properties.
-Shawn
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.