Skip to content

Instantly share code, notes, and snippets.

@dam13n
Created May 8, 2016 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dam13n/6dbad1b48a95850d2ef08591ba726dae to your computer and use it in GitHub Desktop.
Save dam13n/6dbad1b48a95850d2ef08591ba726dae to your computer and use it in GitHub Desktop.
# 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