On Nov 6, 2008, at 11:27 AM, Michael Ash wrote:
On Thu, Nov 6, 2008 at 12:13 AM, Graham Cox <[EMAIL PROTECTED]> wrote:
Is there a way to enumerate the outlets of an object automatically?

In a certain type of controller object I'm finding I'm writing a lot of code
like this:

[myOutlet1 setEnabled:NO];
[myOutlet2 setEnabled:NO];
... etc for another several dozen outlets ...


[...]
Lastly, you could write a proxy object, put it in your nib, and hook
up all of the outlets to it instead. The proxy would intercept all
setFoo: messages by forwarding them to your real object and
simultaneously building a dictionary. This will be sure to only get
real outlets.

I'm not sure I understand -- would the proxy object have outlets to myOutlet1, myOutlet2, etc.?

In any case this reminds me of a silly hack I used in the NeXTstep days, which was to use an NSMatrix to hold an array of things. In this case, the hack would be to create a matrix with one cell for each of the outlets you want to treat as a group, and point to the cell's target to the outlet object. Then, instead of your dozens of setEnabled: calls, you can simply iterate through the matrix. But really this is just a variation on manually setting up the dictionary.

--Andy

_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to