Re: KVO question
Re: KVO question
- Subject: Re: KVO question
- From: Graham Cox <email@hidden>
- Date: Thu, 19 Nov 2015 13:54:40 +1100
Hi guys, thanks for your replies - sorry took a while to get back to this, was in a long meeting.
Anyway, Quincey, I’m not trying to get notified for mutations to the dictionary. The dictionary is being replaced as a single entity wholesale.
The way the font manager works is that for a given attribute change, it asks the first responder to send it the dictionary of attributes for the selected text. (-changeAttributes:) It then mutates a copy of that dictionary (-convertAttributes:) and returns the entire mutated copy. The text view then applies that as a single object to the selected text run.
In my case I’ve actually wrapped the text (attributed string) in another object that splits out specific text-related properties separately, which makes it much easier to bind these properties to particular bits of UI, for example changing the Font. That all works - if I set my -font property, internally it changes the font attribute in the -textAttributes property, I get notifications on both -font and -textAttributes. If I change the text selection, the attributes applying to that run trigger notifications for the font property in my UI. If some other object (e.g. Font Manager) changes the font using its normal mechanism, which updates the -textAttributes property directly, I need notifications to be triggered for the -font property. In fact, they are, because I have +keyPathsForValuesAffectingFont returning textAttributes.
However this was not working consistently for all properties. I was trying to boil it down to generalities hence my dictionaryOfThings and thingy terminology, just to clarify that my understanding of KVO was correct. Seems it was. So my problem must be something specific in my code because in fact this is working for nearly everything, just not all. So if my understanding of KVO is correct, I now know where to look for these few missing pieces.
—Graham
> On 19 Nov 2015, at 11:38 AM, Quincey Morris <email@hidden> wrote:
>
> (sorry, posted the incomplete message by accident)
>
> On Nov 18, 2015, at 16:29 , Roland King <email@hidden> wrote:
>>
>> I didn’t read his original question as saying that
>
> I could easily have got it wrong, but I believe what he was saying was that much of his system was working. The part that doesn’t work is when (e.g.) the Font Manager updates the dictionary directly, by which I mean it changes values in the dictionary, but does not replace the entire dictionary in the model object (it can’t do that, it doesn’t know where to find the model object, or what the property name of the dictionary in the model object is).
>
> In this kind of update, Graham is expecting a KVO notification “for the dictionary”, in order to trigger keyPathsForValuesAffectingThingy. I’m saying that can’t possibly happen.
>
>
_______________________________________________
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