Cocoa Bindings and popups
Cocoa Bindings and popups
- Subject: Cocoa Bindings and popups
- From: Chuck Musser <email@hidden>
- Date: Sun, 18 Jul 2004 13:37:16 -0700
I'm having trouble using Cocoa Bindings to present an array in a popup
button. My main Controller object contains an NSMutableArray called
"rideDescriptionList", which contains a bunch of custom
"RideDescription" objects. These have two NSStrings ("label" and
"description") and an NSNumber ("distance") as instance variables.
I want the popup to show the contents of each object's "label" and, when
new RideDescriptions are added to the array, have them added to the
popup. Here's what I did in Interface Builder:
1.) Created an NSObjectController object called "PostAlias" and set its
"content" outlet to point to my Controller object (which is named
"PostController").
Set the Object Class Name to NSMutableArray in the "Attributes" inspector.
2.) Created an NSArrayController called "RideList" and in the "Bindings"
inspector, set the contentArray binding to this:
Bind to: PostAlias
Controller Key: selection
Model Key Path: rideDescriptionList
Set the Object Class Name to RideDescription in the "Attributes" inspector.
3.) Set the NSPopupButton's bindings to these settings:
content:
Bind to: RideList
Controller Key: arrangedObjects
Model Key Path: <none>
contentValues:
Bind to: RideList
Controller Key: arrangedObjects
Model Key Path: label
I've confirmed that new RideDescription objects are being created, but
they never show up in the popup button. I've missed something, either
conceptually or in the mechanics of making the connections. Does the
above look right? How do I find the missed "connection"? I did pattern
my bindings on the example project at CocoaDevCentral, but obviously I
didn't do it perfectly. I guess what I'm looking for is hints on how to
debug.
Backdrop: I'm a fairly experienced developer, but this is my first Cocoa
program. I've seen opinions here that advise newbies against using
Bindings, but I thought I'd try anyway--I'm not in any hurry to complete
my project, so I figure I might as well take the time to properly use
the technology.
Thanks,
Chuck
_______________________________________________
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.