UICollectionReusableView+RACSignalSupport.m 869 B

1234567891011121314151617181920212223242526272829303132
  1. //
  2. // UICollectionReusableView+RACSignalSupport.m
  3. // ReactiveObjC
  4. //
  5. // Created by Kent Wong on 2013-10-04.
  6. // Copyright (c) 2013 GitHub, Inc. All rights reserved.
  7. //
  8. #import "UICollectionReusableView+RACSignalSupport.h"
  9. #import "NSObject+RACDescription.h"
  10. #import "NSObject+RACSelectorSignal.h"
  11. #import "RACSignal+Operations.h"
  12. #import "RACUnit.h"
  13. #import <objc/runtime.h>
  14. @implementation UICollectionReusableView (RACSignalSupport)
  15. - (RACSignal *)rac_prepareForReuseSignal {
  16. RACSignal *signal = objc_getAssociatedObject(self, _cmd);
  17. if (signal != nil) return signal;
  18. signal = [[[self
  19. rac_signalForSelector:@selector(prepareForReuse)]
  20. mapReplace:RACUnit.defaultUnit]
  21. setNameWithFormat:@"%@ -rac_prepareForReuseSignal", RACDescription(self)];
  22. objc_setAssociatedObject(self, _cmd, signal, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
  23. return signal;
  24. }
  25. @end