Re: Control arrays?
Re: Control arrays?
- Subject: Re: Control arrays?
- From: Matt Neuburg <email@hidden>
- Date: Sun, 16 Jul 2006 09:49:09 -0700
- Thread-topic: Control arrays?
On Sun, 16 Jul 2006 08:43:58 -0500, William Squires <email@hidden>
said:
>Hi all,
> What's the Cocoa equivalent of control arrays in VB6/REALbasic?
>Certainly you could make a controller class that has outlets/actions
>for all the controls in question but this seems like a clunky approach;
>especially inside the controller.
As a REALbasic refugee, this was naturally a question I had to face early
on. The following points of comparison are to be borne in mind:
* If you really are repeating the same control at identical row/column
intervals, you can probably just use an NSMatrix.
* Every control is an NSView, and every NSView can be located within its
superview by means of -[NSView viewWithTag:]. Check the archives for
categories on NSView defining recursive versions of this. Thus, merely
numbering something in IB can be sufficient to reference it from code.
* Outlets/actions are so Jaguar! Consider bindings. In fact, consider
bindings anyway. REALbasic encourages data storage in the interface, which
is bad practice; Cocoa encourages Model-View-Controller, and now that we've
got bindings, it *really* encourages it. On this architecture, you don't
*need* pointers to the controls in question, because things like their data
and their enablement switches and such are directly available to your code
(e.g. in your instance variables).
* Totally unlike REALbasic, ObjectiveC messaging is dynamic. Thus there is a
sense in which control arrays are completely unnecessary, because the
problem that they solve is already solved - namely, your code can decide, at
runtime, what message to send and to whom to send it.
Consideration of those points, in isolation and in combination, will
generally lead to an elegant solution. m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden