This is such a dead simple problem that I think I've encountered a couple times 
over the years and I don't think I've managed to ever find a solution that 
works how I want. I'll break this down into an easy specific example.


Say I have a file type popup in a save sheet for saving an image:


@property NSString * fileType;


- (NSArray *)fileTypes
{
        return [NSArray arrayWithObjects:(id)kUTTypeJPEG, (id)kUTTypePNG, 
(id)kUTTypeTIFF, nil];
}


- (NSArray *)fileTypeNames
{
        return [NSArray arrayWithObjects:@"JPEG", @"PNG", @"TIFF", nil];
}




The popup should display the names, but I want the selected item bound to 
fileType which is one of the UTIs. By my reading of the documentation, this 
_should be very simple_.

Bind:
content -> fileTypes*
contentValues -> fileTypeNames
selectedObject -> fileType


So content provides the list of objects, contentValues provides the 
corresponding titles for each object, selectedObject determines which object is 
selected. Sounds simple, never works. I've never been able to figure it out. It 
seems that if contents provides an array of *strings*, those strings are use as 
the titles *no matter what*.

The documentation for content says: "Unless contentValues is also bound, the 
titles of the items in the NSPopUpButton are derived by invoking description 
for each of the content objects," the documentation for contentValues says "An 
array of strings that are displayed as the items in the NSPopUpButton,"  but no 
matter what on earth I try, it will not work. If I have content bound to, say, 
an array of dictionaries, the popup uses contentValues to display the titles.


So what gives? This should be dead simple and for the life of me I can't figure 
it out. 

Thanks.



*(The docs say content should be bound to an "array controller" — Not sure why 
it says that. An array appears to work the same as an array controller when I 
try it. I've tried creating an array controller bound to fileTypes and binding 
the popup's content to the ac.arrangedObjects but it still doesn't change the 
title situation.)


--
Seth Willits




_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to