Created
May 8, 2016 00:03
-
-
Save dam13n/6dbad1b48a95850d2ef08591ba726dae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# hotfix for ios 9.3.1 KVO issue (perhaps specifically for observering NSDefaults) | |
# reference | |
# http://stackoverflow.com/questions/36193503/kvo-broken-in-ios-9-3 | |
module BubbleWrap | |
module KVO | |
class Registry | |
attr_accessor :observer_last_called_at | |
def observeValueForKeyPath(key_path, ofObject: target, change: change, context: context) | |
key_paths = callbacks[target] || {} | |
blocks = key_paths[key_path] || [] | |
args = change.values_at(*keys) | |
args << key_path | |
@observer_last_called_at ||= 0.0 | |
blocks.each do |block| | |
block.call(*args) | |
end if CFAbsoluteTimeGetCurrent() - 0.005 > @observer_last_called_at | |
@observer_last_called_at = CFAbsoluteTimeGetCurrent() | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment