Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. //
  2. // Copyright (c) 2017/3/20 shinren.pan@gmail.com All rights reserved.
  3. //
  4.  
  5. #import <Foundation/Foundation.h>
  6. NS_ASSUME_NONNULL_BEGIN
  7.  
  8. /**
  9. NSObject category for kvo binding.
  10. */
  11. @interface NSObject (KVO)
  12.  
  13. ///-----------------------------------------------------------------------------
  14. /// @name Category methods
  15. ///-----------------------------------------------------------------------------
  16.  
  17. /**
  18. 移除所有監聽.
  19. */
  20. - (void)kvo_removeObserver;
  21.  
  22. /**
  23. 新增 / 移除一個 keyPath 的監聽.
  24.  
  25. 當 changed = nil 時, 會移除目前 keyPath 的監聽.
  26.  
  27. @param keyPath 要監聽的 keyPath.
  28. @param changed 監聽的 keyPath 數值變動後的 callback.
  29. */
  30. - (void)kvo_observerKayPath:(NSString *)keyPath changed:(void(^__nullable)(void))changed;
  31.  
  32. @end
  33.  
  34. NS_ASSUME_NONNULL_END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement