Re: NSView Names
Re: NSView Names
- Subject: Re: NSView Names
- From: Andy Lee <email@hidden>
- Date: Wed, 27 Feb 2002 19:14:15 -0500
Sorry, I didn't mean to post that twice. What I meant to post the second time was:
At 7:03 PM -0500 2/27/02, I wrote:
>
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.
I just realized the matrix could have just one column, or any dimensions you want. For each cell, the text contents could be the name of the object and the same cell's target outlet could point to the named object.
You could even use an IB matrix to set up a dictionary whose keys are not strings. Just have each cell's target outlet point to the dictionary key, and the delegate outlet point to the dictionary value.
This is a cheap trick I used when I wanted to be able to give an object multiple delegates, for some reason that I forget. (It was years ago, on NextStep.)
--Andy
_______________________________________________
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.