Re: Binding popup contents difficulties [REVISITED]
Re: Binding popup contents difficulties [REVISITED]
- Subject: Re: Binding popup contents difficulties [REVISITED]
- From: Ken Tozier <email@hidden>
- Date: Wed, 31 May 2006 03:50:34 -0400
Although I can get popup bindings working if all I use is an array of
strings, what I'd really like to do is store an array of dictionaries
in my model and have the menu display a specific field from each
dictionary.
Here's the dictionary array structure in my model:
sites (
{id=1, name='Boston', state='Masachusetts'},
{id=2, name='New York', state='New York'},
{id=1, name='Chicago', state='Illinois},
{id=1, name='Los Angeles', state='California'},
etc...
)
Here are the popup bindings I'm attempting in the IB inspector palette:
Value Selection:
contentValues:
Bind to: PopupArrayController
Controller Key: arrangedObjects
Model Key path: name
When the nib loads, it crashes my app with the following errors:
2006-05-31 03:05:50.846 QuarkXPress[8608] [<_NSControllerArrayProxy
0x11776e80> valueForUndefinedKey:]: this class is not key value
coding-compliant for the key name.
2006-05-31 03:05:50.846 QuarkXPress[8608] *** Uncaught exception:
<NSUnknownKeyException> [<_NSControllerArrayProxy 0x11776e80>
valueForUndefinedKey:]: this class is not key value coding-compliant
for the key name.
What's really odd is that using the same dictionary, a similar set of
bindings work perfectly in a table column
Value:
value:
Bind to: ColumnArrayController
Controller Key: arrangedObjects
Model Key path: name
So why isn't this working in the popup? I assume the
"arrangedObjects" refers to the array of dictionaries and as can be
clearly seen each dictionary contains a "name" field so I don't
understand why it doesn't work.
Any bindings gurus point out what I'm doing wrong here?
Thanks
Ken
On May 29, 2006, at 1:20 PM, Ken Tozier wrote:
Well,made a little progress, but now what's happening is that the
entire array appears as a single menu item.
I think there is something fundamental I'm not understanding about
binding and array controllers. The purpose of the accessor method
in the model class is to provide the entire contents of the array,
no? Unfortunately though this seems to mash the array into a single
item (like going [array description]) and placing this description
as the menu's sole item. How exactly are you supposed to fill a
menu? There's no mechanism to specify the model key path for items
within an array say like sites[#].
Please help almost 8 hours now trying to fill the contents of a
single menu. This is getting extremely frustrating.
Thanks
Ken
On May 29, 2006, at 10:06 AM, Ken Tozier wrote:
Still haven't figured it out yet but here's the most recent error
I'm getting
2006-05-29 09:48:39.668 QuarkXPress[2701] [<NSArrayController
0x117b9c10> addObserver:<NSSelectionBinder 0x117bfbf0>
forKeyPath:@"site.name" options:0x0 context:0x0] was sent to an
object that is not KVC-compliant for the "site" property.
Here's the accessor that shows that the target class is indeed KVC
compliant for the "site" property.
- (NSArray *) site
{
return [properties objectForKey: @"site"];
}
Here's the structure of the return from the above method
(
{id=1, name='Boston'},
{id=2, name='New York'},
{id=3, name='Chicago'},
{id=4, name='Los Angeles'},
etc...
)
I've looked at all of mmalc's examples here http://
homepage.mac.com/mmalc/CocoaExamples/controllers.html particularly
the "PopUpTest" project and I just don't see what I'm doing that
is all that different, other than his example is for shared
defaults while mine is for a popup in a dialog
I've been futzing with this for around four hours now trying every
combination of content, content + contentValues, selected values I
can think of, nothing works. What the heck am I doing wrong here?
On May 29, 2006, at 3:01 AM, Ken Tozier wrote:
Hi
I'm having some problems binding the contents of a popup button.
Here's what I've done so far.
1. Create a properties dictionary in my NSWindowController
subclass with the following structure
{
site = {
{id=1, name='Boston'},
{id=2, name='New York'},
{id=3, name='Chicago'},
{id=4, name='Los Angeles'},
etc...
}
}
2. create an accessor method to get the sites from the property
dictionary
- (NSArray *) site
{
return [properties objectForKey: @"site"];
}
3. In the nib file, set the custom class of the file's owner to
MyWindowController.
4. Create an NSArrayController in the nib and connect its
"content" outlet to the file owner
5. Add a "site" key to the array controller.
6. Tried binding the popup to the array controller in each of the
following ways:
- content
Bind to: PopupArrayController
Controller Key: arranged objects
Model key path: <tried leaving empty and entering "site">
-> Result empty popup
- content + contentObjects
Content:
Bind to: PopupArrayController
Controller Key: arranged objects
Model key path: <tried leaving empty and entering "site">
Content Objects:
Bind to: PopupArrayController
Controller Key: selection
Model key path: <tried leaving empty and entering "site">
-> Result empty popup
- contentValues
Bind to: PopupArrayController
Controller Key: site
Model key path: <tried leaving empty and entering "site">
-> Result empty popup
Anyone point out what I'm doing wrong here?
Thanks for any help
Ken
P.S. does anyone know of a good site that explains binding
options in detail? There's so many options for each binding
property, it's really confusing trying to figure out why they
were created in the first place and what situations call for what
options.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40comcast.net
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40comcast.net
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40comcast.net
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden