Theocacao
Leopard
Design Element
Comment on "Lazy Loading of KVO Observed Properties"
by Scott Guelich — Jun 17
Thanks for posting this. I never realized there was a side-effect gotcha from calling a setter.

But I also agree with ssp. If you hadn't been loading that value "lazily", no KVO notification would be sent because the image would have been initialized during the enclosing object's initialization -- before any KVO observers could have possibly started watching it. Sending a notification when it gets set later seems to be exposing an internal implementation detail.

Furthermore, if setMyImage: is public then your interface allowing another object to override the default image, but (if I'm correctly understanding what you're saying about setters implicitly calling getters) wouldn't this cause your object to unnecessarily load the default image from disk -- right before it's overwritten with the desired image?
Back to "Lazy Loading of KVO Observed Properties"
Design Element

Copyright © Scott Stevenson 2004-2015