Re: Why do I receive KVO notification when new value IS the old value?

2009-07-08 Thread Graham Cox
On 09/07/2009, at 10:18 AM, Jerry Krinock wrote: Maybe this is one of the reasons why it is quite common nowadays that when a user clicks "Undo" 10 times, something is seen to happen on only 5 or 6 of the clicks. This is one of my pet hates too. NSUndoManager could do with a couple of th

Re: Why do I receive KVO notification when new value IS the old value?

2009-07-08 Thread John C. Randolph
On Jul 8, 2009, at 3:05 PM, Jerry Krinock wrote: Why do I receive KVO notifications when a key is set to the same value that it already is? Because the notification mechanism doesn't know or care if you're setting the same value that's already there. -jcr

Re: Why do I receive KVO notification when new value IS the old value?

2009-07-08 Thread Jerry Krinock
On 2009 Jul 08, at 16:20, Quincey Morris wrote: Excuse me while I put on my properties-are-behavior crusader's hat. :) OK, I get it. Since we don't always use @synthesize, @dynamic, or Xcode's "Scripts" menu (noting the if() test in this implementation) ... - (void)setName:(NSString *)va

Re: Why do I receive KVO notification when new value IS the old value?

2009-07-08 Thread Graham Cox
On 09/07/2009, at 9:49 AM, Kiel Gillard wrote: To prevent this behaviour, you could override setName: to only change the value when the pointers are not the same. That doesn't change the automatic KVO notification behaviour, which takes effect 'outside' of the method itself. Whatever the

Re: Why do I receive KVO notification when new value IS the old value?

2009-07-08 Thread Kiel Gillard
To prevent this behaviour, you could override setName: to only change the value when the pointers are not the same. Kiel On 09/07/2009, at 8:05 AM, Jerry Krinock wrote: Why do I receive KVO notifications when a key is set to the same value that it already is? This happens not only when th

Re: Why do I receive KVO notification when new value IS the old value?

2009-07-08 Thread Quincey Morris
On Jul 8, 2009, at 15:05, Jerry Krinock wrote: Why do I receive KVO notifications when a key is set to the same value that it already is? This happens not only when the new and old values are -isEqual:, but when they are identically the same pointer. I can't think of any reason why anyon

Re: Why do I receive KVO notification when new value IS the old value?

2009-07-08 Thread BJ Homer
Likewise, what if I had a program that was counting the number of X events per 10 seconds, and I wanted to add a data point to a list every time it was updated? I would definitely want to record the same number twice in a row. It may not be a common case, but reporting the value enables situations

Re: Why do I receive KVO notification when new value IS the old value?

2009-07-08 Thread Greg Guerin
Jerry Krinock wrote: This happens not only when the new and old values are -isEqual:, but when they are identically the same pointer. I can't think of any reason why anyone would want notification of a no-op. What if the operation isn't a no-op? What if the operation represented some ki

Why do I receive KVO notification when new value IS the old value?

2009-07-08 Thread Jerry Krinock
Why do I receive KVO notifications when a key is set to the same value that it already is? This happens not only when the new and old values are -isEqual:, but when they are identically the same pointer. I can't think of any reason why anyone would want notification of a no-op. I underst