I saw these lines in a demo project, but I couldn\'t understand why it did that.
[self willChangeValueForKey:@\"names\"];
[self didChangeValueForKey:@\"names\"];
Agree with Barry. I just meet the same problem. Here is a case of using those two methods. I declared a readonly property. So I can't use the property's accessor to change the value.
@property (nonatomic, readonly) BOOL var;
When I want to change the "var", I need to call these two methods manually. Otherwise, observers won't get notified.
self willChangeValueForKey:@"var"];
var = YES;
[self didChangeValueForKey:@"var"];
Posting this in July 2013, and it no longer seems to be necessary to call will/didChangeValueForKey. It seems to be taken care of automatically, even if you have a custom setter.