Re: Enumerating outlets automatically?
Re: Enumerating outlets automatically?
- Subject: Re: Enumerating outlets automatically?
- From: Matt Neuburg <email@hidden>
- Date: Thu, 06 Nov 2008 08:15:48 -0800
- Thread-topic: Enumerating outlets automatically?
On Thu, 6 Nov 2008 16:13:52 +1100, Graham Cox <email@hidden> said:
>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 ...
>
>If I could get a list of outlets (maybe as a dictionary with the ivar
>name as key) I could probably find much easier ways to do stuff to
>each one. I suspect the answer is no but I thought I'd ask anyway...
I had a similar problem in an app I wrote way back in the dark days before
bindings - and a dictionary is exactly what I ended up using. I didn't
generate the dictionary automatically, because my requirements were quite
complicated; the window had several "states", and when there was a change in
state, a lot of interface items had to change their states in some way,
simultaneously. The dictionary was in fact generated from a textfile loaded
as the app started up (so that I could maintain it easily without
hard-coding all the rules into the app itself), and the key was a tag
identifier, which was matched up with the desired control within the window
using a recursive form of viewWithTag:. m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden