RACKVOProxy.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. //
  2. // RACKVOProxy.h
  3. // ReactiveCocoa
  4. //
  5. // Created by Richard Speyer on 4/10/14.
  6. // Copyright (c) 2014 GitHub, Inc. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. /// A singleton that can act as a proxy between a KVO observation and a RAC
  10. /// subscriber, in order to protect against KVO lifetime issues.
  11. @interface RACKVOProxy : NSObject
  12. /// Returns the singleton KVO proxy object.
  13. + (instancetype)sharedProxy;
  14. /// Registers an observer with the proxy, such that when the proxy receives a
  15. /// KVO change with the given context, it forwards it to the observer.
  16. ///
  17. /// observer - True observer of the KVO change. Must not be nil.
  18. /// context - Arbitrary context object used to differentiate multiple
  19. /// observations of the same keypath. Must be unique, cannot be nil.
  20. - (void)addObserver:(__weak NSObject *)observer forContext:(void *)context;
  21. /// Removes an observer from the proxy. Parameters must match those passed to
  22. /// addObserver:forContext:.
  23. ///
  24. /// observer - True observer of the KVO change. Must not be nil.
  25. /// context - Arbitrary context object used to differentiate multiple
  26. /// observations of the same keypath. Must be unique, cannot be nil.
  27. - (void)removeObserver:(NSObject *)observer forContext:(void *)context;
  28. @end