NSObject+SafeKVO.h 774 B

123456789101112131415161718192021222324252627282930313233
  1. //
  2. // NSObject+SafeKVO.h
  3. // WMZPageController
  4. //
  5. // Created by wmz on 2019/10/16.
  6. // Copyright © 2019 wmz. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. NS_ASSUME_NONNULL_BEGIN
  10. @interface NSObject (SafeKVO)
  11. /*!
  12. @method
  13. @abstract 移除所有观察的keypath
  14. */
  15. - (void)removeAllObserverdKeyPath:(NSObject*)VC withKey:(NSString*)key;
  16. /*!
  17. @method
  18. @abstract 安全增加观察者
  19. */
  20. - (void)pageAddObserver:(nonnull NSObject *)observer forKeyPath:(nonnull NSString *)keyPath options:(NSKeyValueObservingOptions)options context:(nullable void *)context;
  21. /*!
  22. @method
  23. @abstract 安全删除观察者
  24. */
  25. - (void)paegRemoveObserver:(nonnull NSObject *)observer forKeyPath:(nonnull NSString *)keyPath context:(nullable void *)context;
  26. @end
  27. NS_ASSUME_NONNULL_END