Use of context for KVO Observation
suggest change-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context
Context is important if you ship your class for others to use. Context lets your class’s observer verify that it is your observer which is being called.
The problem with not passing a context is that if someone subclasses your class and registers an observer for the same object and the same key, and does not pass a context, then the superclass observer can be called multiple times.
A variable which is unique and internal for your use is a good context.
For more information:
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents