Re: Cocoa Bindings and popups
Re: Cocoa Bindings and popups
- Subject: Re: Cocoa Bindings and popups
- From: Scott Anguish <email@hidden>
- Date: Tue, 20 Jul 2004 00:46:48 -0400
On Jul 20, 2004, at 12:32 AM, Chuck Musser wrote:
Create an NSArrayController and bind it's content array to the
variable that contains the ride list
then bind the popup menu to that array controller.
When I create an NSArrayController, the binding inspector's Bind To
field for contentArray only offers two choices: Shared User Defaults
and Files Owner (NSApplication). In my application, the main
controller for the GUI is a subclass of NSObject called
PostController. This object contains the instance variable that holds
the NSMutableArray that I want to bind to the popup. So I can't figure
out how to make the connection. I tried the following avenues in
Interface Builder:
Ah... ok.. yeah. Currently IB only allows you to select items to bind
to that are either part of the file's owner, shared application, shared
user defaults, or a top level controller (bindings type controller) in
IB. You'd have to make any other connections programatically using
bindTo: when the app starts up.
typically this can be worked around using the file's owner. It's a
proxy for the object that is the owner of the nib. If you're dealing
with a document application the DOcument.nib file's owner is the
Document subclass.
in the case of a simple single nib application, who is the object that
is holding the RidesList array? can you get to it via
filesOwner.delegate.ridesList perhaps?
1.) I tried subclassing NSObjectController to make a class that would
replace my current controller. My theory was that IB wouldn't allow me
to bind to something that wasn't an NSObjectController or a descendant
thereof. Unfortunately, IB wouldn't allow me to instantiate my new
subclass. I highlighted it in the Classes tab, but the Instantiate
menu item was grayed out. So I guess the two questions here are: Is
the the right approach? and How come I couldn't instantiate the class?
2.) I tried creating a new NSArrayController, control-dragged a
connection from it to my main controller, and connected the "content"
outlet.
Again, the hope was that my main controller object would show up in
the Bind To popup for the NSArrayController's contentArray. Sadly this
did not work either.
in that case it doesn't need to show up,l what you'd bind to is the
array controller.
So it looks like I've got structural problems. This project is in its
early stages, so I'm certainly not averse to rejiggering it and
starting over. I'm just not sure what to try next.
How are you adding the items to the array?
My main controller object also manages a sheet that allows the user to
enter information about a new item. That code adds items to the
NSMutableArray. I have confirmed that new objects are added to the
array.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.