NSObject+FBKVOController.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. Copyright (c) 2014-present, Facebook, Inc.
  3. All rights reserved.
  4. This source code is licensed under the BSD-style license found in the
  5. LICENSE file in the root directory of this source tree. An additional grant
  6. of patent rights can be found in the PATENTS file in the same directory.
  7. */
  8. #import <Foundation/Foundation.h>
  9. #import "FBKVOController.h"
  10. NS_ASSUME_NONNULL_BEGIN
  11. /**
  12. Category that adds built-in `KVOController` and `KVOControllerNonRetaining` on any instance of `NSObject`.
  13. This makes it convenient to simply create and forget a `FBKVOController`,
  14. and when this object gets dealloc'd, so will the associated controller and the observation info.
  15. */
  16. @interface NSObject (FBKVOController)
  17. /**
  18. @abstract Lazy-loaded FBKVOController for use with any object
  19. @return FBKVOController associated with this object, creating one if necessary
  20. @discussion This makes it convenient to simply create and forget a FBKVOController, and when this object gets dealloc'd, so will the associated controller and the observation info.
  21. */
  22. @property (nonatomic, strong) FBKVOController *KVOController;
  23. /**
  24. @abstract Lazy-loaded FBKVOController for use with any object
  25. @return FBKVOController associated with this object, creating one if necessary
  26. @discussion This makes it convenient to simply create and forget a FBKVOController.
  27. Use this version when a strong reference between controller and observed object would create a retain cycle.
  28. When not retaining observed objects, special care must be taken to remove observation info prior to deallocation of the observed object.
  29. */
  30. @property (nonatomic, strong) FBKVOController *KVOControllerNonRetaining;
  31. @end
  32. NS_ASSUME_NONNULL_END