Sunday, January 6, 2013 [Tweets] [Favorites]

@property(weak) Isn’t KVO-Compliant

Mike Abdullah:

By declaring a @property as weak, it’s now impossible for it to be KVO-compliant. Weak properties are implemented simply by marking the underlying ivar as weak. If it gets cleared out to nil, that is handled directly by the runtime, without any sort of notification. Callers of the property will correctly start to receive nil, but none of your code know precisely it happened. Thus there’s no good way for a KVO notification to be posted at the time.

It seems like NSKeyValueObserving is due for a redesign.

Comments

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment