From 30e2d9e9f668be80f9a584fd2c8f13f3907d940a Mon Sep 17 00:00:00 2001 From: Ash Furrow Date: Fri, 25 Oct 2013 15:19:11 -0400 Subject: [PATCH] First steps toward using ReactiveViewModel. --- FRP/FRPGalleryViewController.m | 10 +++++----- FRP/FRPGalleryViewModel.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/FRP/FRPGalleryViewController.m b/FRP/FRPGalleryViewController.m index 1c06774..9f50165 100644 --- a/FRP/FRPGalleryViewController.m +++ b/FRP/FRPGalleryViewController.m @@ -39,7 +39,7 @@ static NSString *CellIdentifier = @"Cell"; self = [self initWithCollectionViewLayout:flowLayout]; if (!self) return nil; - self.viewModel = [FRPGalleryViewModel new]; + self.viewModel = [[FRPGalleryViewModel alloc] init]; return self; } @@ -57,7 +57,7 @@ static NSString *CellIdentifier = @"Cell"; // Binding to view model @weakify(self); - [RACObserve(self.viewModel, photosArray) subscribeNext:^(id x) { + [RACObserve(self.viewModel, model) subscribeNext:^(id x) { @strongify(self); [self.collectionView reloadData]; }]; @@ -71,7 +71,7 @@ static NSString *CellIdentifier = @"Cell"; @strongify(self); NSIndexPath *indexPath = arguments.second; - FRPFullSizePhotoViewModel *viewModel = [[FRPFullSizePhotoViewModel alloc] initWithPhotoModelArray:self.viewModel.photosArray initialPhotoIndex:indexPath.item]; + FRPFullSizePhotoViewModel *viewModel = [[FRPFullSizePhotoViewModel alloc] initWithPhotoModelArray:self.viewModel.model initialPhotoIndex:indexPath.item]; FRPFullSizePhotoViewController *viewController = [[FRPFullSizePhotoViewController alloc] init]; viewController.viewModel = viewModel; @@ -100,13 +100,13 @@ static NSString *CellIdentifier = @"Cell"; #pragma mark - UICollectionViewDataSource Methods -(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { - return self.viewModel.photosArray.count; + return self.viewModel.model.count; } -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { FRPCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath]; - [cell setPhotoModel:self.viewModel.photosArray[indexPath.row]]; + [cell setPhotoModel:self.viewModel.model[indexPath.row]]; return cell; } diff --git a/FRP/FRPGalleryViewModel.h b/FRP/FRPGalleryViewModel.h index 053ae60..e87c700 100644 --- a/FRP/FRPGalleryViewModel.h +++ b/FRP/FRPGalleryViewModel.h @@ -8,8 +8,8 @@ #import -@interface FRPGalleryViewModel : NSObject +@interface FRPGalleryViewModel : RVMViewModel -@property (nonatomic, readonly) NSArray *photosArray; +@property (nonatomic, readonly, strong) NSArray *model; @end