From 32b89c130d8a0c3ff5d306a7d0d86edb612834e8 Mon Sep 17 00:00:00 2001 From: Justin Spahr-Summers Date: Fri, 18 Oct 2013 00:42:01 -0700 Subject: [PATCH] Turn photoModel into a property and observe it --- FRP/FRPCell.h | 2 +- FRP/FRPCell.m | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/FRP/FRPCell.h b/FRP/FRPCell.h index 374c54a..30df476 100644 --- a/FRP/FRPCell.h +++ b/FRP/FRPCell.h @@ -12,6 +12,6 @@ @interface FRPCell : UICollectionViewCell --(void)setPhotoModel:(FRPPhotoModel *)photoModel; +@property (nonatomic, strong) FRPPhotoModel *photoModel; @end diff --git a/FRP/FRPCell.m b/FRP/FRPCell.m index adec78b..11b3e3e 100644 --- a/FRP/FRPCell.m +++ b/FRP/FRPCell.m @@ -30,16 +30,12 @@ imageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; [self.contentView addSubview:imageView]; self.imageView = imageView; + + RAC(self.imageView, image) = [[RACObserve(self, photoModel.thumbnailData) ignore:nil] map:^(NSData *data) { + return [UIImage imageWithData:data]; + }]; return self; } --(void)setPhotoModel:(FRPPhotoModel *)photoModel { - RACSignal *prepareForReuseSignal = [self rac_signalForSelector:@selector(prepareForReuse)]; - - RAC(self.imageView, image) = [[[RACObserve(photoModel, thumbnailData) ignore:[NSNull null]] map:^(NSData *data) { - return [UIImage imageWithData:data]; - }] takeUntil:prepareForReuseSignal]; -} - @end