Re: NSView Names
Re: NSView Names
- Subject: Re: NSView Names
- From: Andy Lee <email@hidden>
- Date: Wed, 27 Feb 2002 18:41:56 -0500
At 10:58 PM +0000 2/27/02, Chris Purcell wrote:
>
I can think of two alternatives. One, add a "name" property to the object. Two, set up a dictionary storing each window under its name. Alas, both require modifying IB to some extent, either to change the properties pane of the object (ickk) or to allow a nib to set up an NSDictionary. (On the latter note, does anyone have code that does this, and/or something better? I have made an attempt and would appreciate the comparison.)
>
Here's a lazy man's approach to setting up an NSDictionary without modifying IB. Create a non-displaying window, and put an NSMatrix of text cells into it. The matrix should have two columns and as many rows as you want to have dictionary entries. Type the object names into the left column. Connect the cells of the second column to the objects you want to name, using the "target" outlet. Create and instantiate a class which has an outlet pointing to the matrix. In this class, have an -awakeFromNib method that traverses the matrix and builds up the NSDictionary.
Simson, I don't know if you'll find this any less "gross and awkward" than the Tooltip trick. If nothing else, this would free up tooltips to be used for their original purpose in case you ever want that.
--Andy
>
Before going further, would either of these actually help your situation?
>
>
Kritter
>
>
>Thanks. I'm somewhat familiar with the concept of outlets.
>
>
>
>However, I don't want to get the ids of an object. I want the object to be
>
>able to get the name that was assigned to it through the Interface Builder's
>
>NIB document window. That is, I want an object to be able to determine its
>
>own name.
>
>
>
>Interface Builder 0.8 used named objects as a mechanism for learning the id
>
>of an object. This was used before the connection metaphor was implemented.
>
>However, the names are useful for an application that I am developing. I'm
>
>currently using the Tooltip NSString * as a proxy for the name, and then
>
>having the object remove its Tooltip, but this is gross and awkward.
_______________________________________________
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.