My custom view implements -optionDescriptionsForBinding: as follows:

- (NSArray *)optionDescriptionsForBinding:(NSString *)binding {
   NSMutableArray *descs = [NSMutableArray arrayWithArray:[super 
optionDescriptionsForBinding:binding]];

   if([binding isEqualToString:@“foo"]) {
       NSAttributeDescription *desc = [[[NSAttributeDescription alloc] init] 
autorelease];

       [desc setName:NSConditionallySetsHiddenBindingOption];
       [desc setAttributeType:NSBooleanAttributeType];
       [desc setDefaultValue:[NSNumber numberWithBool:NO]];
       [descs addObject:desc];

       desc = [[[NSAttributeDescription alloc] init] autorelease];
       [desc setName:NSConditionallySetsEnabledBindingOption];
       [desc setAttributeType:NSBooleanAttributeType];
       [desc setDefaultValue:[NSNumber numberWithBool:NO]];
       [descs addObject:desc];

       desc = [[[NSAttributeDescription alloc] init] autorelease];
       [desc setName:NSConditionallySetsEditableBindingOption];
       [desc setAttributeType:NSBooleanAttributeType];
       [desc setDefaultValue:[NSNumber numberWithBool:YES]];
       [descs addObject:desc];
   }

   return descs;
}

As expected, this causes Interface Builder to show the checkboxes for these 
three options. However, if I try to click one of them, 
bind:toObject:withKeyPath:options: gets called twice — the first time with 
these three options properly present in the options dictionary, but the second 
time with the options dictionary set to nil (or to a dictionary containing 
nothing but the value transformer, if there is one). The result of this is that 
trying to click one of the check boxes causes the checkbox to change 
momentarily but then flicker back to the default setting, and there’s no way to 
actually set these binding options.

What’s more, I had a look at some of the standard Cocoa views that implement 
bindings, such as NSTextView, and discovered that sending 
-optionDescriptionsForBinding: to them returns an empty array — yet, the 
aforementioned options appear for these views in Interface Builder. So is there 
some other, better way to make “Conditionally sets enabled” and friends show up 
for a view other than returning those options in 
-optionDescriptionsForBinding:? What’s the approved way to do it?

Thanks,
Charles_______________________________________________

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 arch...@mail-archive.com

Reply via email to