Skip navigation.
 
mlRe: wrapping multiple IBOutlet objects for reuse
FROM : Keary Suska
DATE : Tue Jun 24 22:36:03 2008

6/24/08 12:21 PM, also sprach <email_removed>:

> Is there a way to use class objects that wrap multiple IBOutlet objects?
>
> The app I am working on has groups of interface elements that are
> repeated on the interface and in the code. Let me see if I can
> illustrate what I mean:
>
> The window looks (slightly) like this:
>
> (button_set_src_1) (add) (delete) (halt) (progressbar1)
> (button_set_src_2) (add) (delete) (halt) (progressbar2)
> (button_set_src_3) (add) (delete) (halt) (progressbar3)
>

<snip>
> This is pretty klunky, and I would like something more like:
> @interface Element : NSObject
> {
> IBOutlet NSTextField          *src;
> IBOutlet NSProgressIndicator  *progressbar;
> IBOutlet NSTextField          *dest;
> IBOutlet NSButton            *halt;
> IBOutlet NSButton            *remove;
> IBOutlet NSTextField  *precentdone;
> }
> @end

<snip>
> But, while the code part seems easy enough, I am not sure how it
> would work with Interface Builder. Is it possible to create a custom
> class like that (Element), and place instances of it on a window in
> IBuilder, hook up the controls in the code? Maybe someone can help me
> with terminology or examples? I know what I want, but I don't know
> enough about Cocoa yet to express it.


I would have each "row" of controls as a vanilla NSView in a separate nib.
Your controller class, which would be the nib owner, could manage each "set"
of controls. You'll need to familiarize yourself with nib loading
(particularly NSNib's methods) and the cocoa drawing system (particularly
views and subviews, and the coordinate system), at least. There may be more
that I am not thinking of.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

Related mailsAuthorDate
mlwrapping multiple IBOutlet objects for reuse Paul Archibald Jun 24, 20:21
mlRe: wrapping multiple IBOutlet objects for reuse Keary Suska Jun 24, 22:36
mlRe: wrapping multiple IBOutlet objects for reuse Markus Spoettl Jun 24, 23:24