Re: Using multiple bindings to enable a button
Re: Using multiple bindings to enable a button
- Subject: Re: Using multiple bindings to enable a button
- From: Ken Thomases <email@hidden>
- Date: Wed, 11 Feb 2015 01:34:35 -0600
On Feb 11, 2015, at 12:31 AM, Quincey Morris <email@hidden> wrote:
> On Feb 10, 2015, at 21:45 , Steve Mills <email@hidden> wrote:
>>
>> I'm not sure about the KVO compliancy. I'm still a newbie in this area. Let me give you the rundown on the stuff that deals with it.
>>
>> @interface WindController : NSWindowController
>> @property (weak) NSString* comboStringValue;
>> @end
>>
>> The window has:
>>
>> A Combobox binds its Value to File's Owner.self.comboStringValue, because I've learned you can't bind directly to a field's stringValue.
> However, a weak property is never KVO compliant, because its value can potentially change (to nil) at any time, without going through the property setter, which is what supplies the KVO compliance.
> Try changing the “comboStringValue” property to strong. Anyway, it makes no sense for it to be weak.
I recommend making the property "copy" rather than "strong". First, it's a value property not a relationship property and those should almost always be "copy". Second, it's also conceivable that the binding passes a reference to an internal mutable string to the property. That, too, can change in a non-KVO-compliant manner.
Regards,
Ken
_______________________________________________
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