Re: wrapping multiple IBOutlet objects for reuse
I think you'd be better off doing things programmatically, but leverage the framework as much as possible. I'm developing on the iPhone, so if you're not, I hope there are analogous built-in classes that you can leverage: 1. Since it looks like you want rows of objects, I'd leverage UITableView (as an IBOutlet) since you can then dynamically insert/delete rows of similar groups of objects. 2. For each row, I'd use a custom UITableViewCell in which you would define the elements (here, I'd do it programmatically) you specify, namely: UITextField *src1; UIProgressIndicator *progressbar1; UITextField *dest1; UIButton *halt1; UIButton *remove1; UITextField *precentdone1; HTH, Chuck ___ 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]
wrapping multiple IBOutlet objects for reuse
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 (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]
Re: wrapping multiple IBOutlet objects for reuse
6/24/08 12:21 PM, also sprach [EMAIL PROTECTED]: 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 ___ 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]
Re: wrapping multiple IBOutlet objects for reuse
On Jun 24, 2008, at 1:36 PM, Keary Suska wrote: 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. In addition to what Keary Suska said, you can use NSViewController to manage the custom compound view located it's own NIB. NSViewController will manage memory, help with bindings and general management. Basically everyhing you would have to do manually otherwise. NSViewController is available in 10.5. See http://developer.apple.com/documentation/Cocoa/Reference/NSViewController_Class/Introduction/Introduction.html for more information. The basic steps are these: 1) create a custom NSViewController derived class (MyViewController) which will manage one row of controls in your UI (define outlets for one row) 2) create a view XIB/NIB in Xcode and set it up in IB. 3) In IB make sure you set the File's Owner class to your custom NSViewController class. 4) Set the view outlet of the File's Owner to your compound view in the XIB 5) Add other views, controls buttons and wire them to the outlets in the custom controller. 6) Prepare your main UI by setting up a container view that will host the compound view and create an outlet for that view (container). 7) In the main controller (the one that embeds the individual rows), create an instance of your view controller like this: myViewController = [[MyViewController alloc] initWithNibName:@MyViewNib bundle:nil]; (release it in -dealloc of that class). 8) Embed the compound view in your container using: [container addSubview:[myViewController view]]; [[myViewController view] setFrame:WHERE_YOUR_WANT_IT]; [[myViewController view] setHidden:NO]; 9) You can also use NSViewControllers representedObject to wire bindings or add your own UI management code that loads and saves data. 10) Repeat steps 7-9 for each row you need to display. In your case you would have an array of MyViewControllers than let you access the individual rows. Hope this helps. Regards Markus -- __ Markus Spoettl smime.p7s Description: S/MIME cryptographic signature ___ 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]