Binding to an accessor that is only valid for subclass (was: Node hierarchy with subclasses)
Binding to an accessor that is only valid for subclass (was: Node hierarchy with subclasses)
- Subject: Binding to an accessor that is only valid for subclass (was: Node hierarchy with subclasses)
- From: BareFeet <email@hidden>
- Date: Tue, 2 Feb 2010 17:39:14 +1100
> On Jan 29, 2010, at 9:38 AM, Jerry Krinock wrote:
>
>>
>> The problem is that when a subclass A is selected, the UI elements bound to subclass B no longer have valid bindings so generate an error. How can I solve this?
>
> You can also uncheck the "Raises For Not Applicable Keys" in the bindings inspector pain in Interface Builder for your text fields.
Thanks for the tip. Once I read it, it seemed like the logical solution. However, it doesn't seem to make any difference. All I could find in the documentation about that checkbox/attribute was:
NSRaisesForNotApplicableKeysBindingOption
An NSNumber object containing a Boolean value that specifies if an exception is raised when the binding is bound to a key that is not applicable—for example when an object is not key-value coding compliant for a key.
To recall, I have something like this:
@interface TopClass : NSObject
{
// some ivars
}
// some accessors
@end
@interface SubClass : TopClass
{
NSString* subValue;
}
- (NSString) subValue;
@end
I have an NSTreeController that contains a list of TopClass and SubClass items. The user selects an item in that list.
I have a text field in Interface Builder whose value is bound (ie via bindings) to the subValue accessor, ie: NSTreeController -> selection.subValue
Obviously, the subValue accessor is only valid if the currently selected item is a SubClass object. If the user selects a TopClass item, it throws an exception. How can I prevent this?
Thanks,
Tom
BareFeet
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden