How can I monitor objective-c method return value changes
I'm using Spark开发者_运维知识库le http://sparkle-project.org/ framework for autoupdates in my application. I have a UI item which enables/disables automatic updates downloads, but I can use neither Interface Builder bindings as stated in documentation for Sparkle, nor KVO, because there is no property for automatic updates download - only getter and setter methods. Can I hook the setter method and have a callback invoked when this option changes through Sparkle's interface interaction.
What can I do in this situation?
Thank you.
If there are getter and setter methods, then there is implicitly a property, even if one is not declared. You can use KVO with it just fine. In fact, for many years, this was the only way to do KVO; there were no explicit properties. Cocoa treats anything with an appropriately named getter and setter as a property.
Bindings use the same mechanism, so you should be able to use bindings as well. Don't let the lack of a declared property scare you off.
Why do you need to monitor these changes? The most application I know check for updates on startup only and not during runtime. So you would check and update or just continue with the application.
If there is no other way a timer (NSTimer) will always work to check things periodically.
精彩评论