• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
wrapping multiple IBOutlet objects for reuse
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

wrapping multiple IBOutlet objects for reuse


  • Subject: wrapping multiple IBOutlet objects for reuse
  • From: Paul Archibald <email@hidden>
  • Date: Tue, 24 Jun 2008 11:21:50 -0700

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)

And the code looks (slightly) like this:

IBOutlet NSTextField         	*src1;
IBOutlet NSProgressIndicator 	*progressbar1;
IBOutlet NSTextField         	*dest1;
IBOutlet NSButton            	*halt1;
IBOutlet NSButton            	*remove1;
IBOutlet NSTextField		*precentdone1;

IBOutlet NSTextField         	*src2;
IBOutlet NSProgressIndicator 	*progressbar2;
IBOutlet NSTextField         	*dest2;
IBOutlet NSButton            	*halt2;
IBOutlet NSButton            	*remove3;
IBOutlet NSTextField		*precentdone2;

IBOutlet NSTextField         	*src3;
IBOutlet NSProgressIndicator 	*progressbar3;
IBOutlet NSTextField         	*dest3;
IBOutlet NSButton            	*halt3;
IBOutlet NSButton            	*remove3;
IBOutlet NSTextField		*precentdone3;

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

...
	Element *e1;
	Element *e2;
	Element *e3;

or even better, an array of Elements:

	NSArray *elements [[NSArray alloc] initWithObjects:
		e1, e2, e3];
		.... not sure exactly how to do this, but you get the idea..


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.
_______________________________________________


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


  • Follow-Ups:
    • Re: wrapping multiple IBOutlet objects for reuse
      • From: Keary Suska <email@hidden>
  • Prev by Date: Re: NSTreeController filter contents
  • Next by Date: CFSocket and wifi
  • Previous by thread: Re: NSCalendarDate dayOfWeek
  • Next by thread: Re: wrapping multiple IBOutlet objects for reuse
  • Index(es):
    • Date
    • Thread