mirror of
https://github.com/zhigang1992/FunctionalReactivePixels.git
synced 2026-04-30 13:01:42 +08:00
Migrated away from RACTuple as view model model.
This commit is contained in:
@@ -11,31 +11,34 @@
|
||||
// Model
|
||||
#import "FRPPhotoModel.h"
|
||||
|
||||
|
||||
@interface FRPFullSizePhotoViewModel ()
|
||||
|
||||
// Private access
|
||||
@property (nonatomic, assign) NSInteger initialPhotoIndex;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FRPFullSizePhotoViewModel
|
||||
|
||||
-(instancetype)initWithPhotoArray:(NSArray *)photoArray initialPhotoIndex:(NSInteger)initialPhotoIndex {
|
||||
self = [self initWithModel:photoArray];
|
||||
if (!self) return nil;
|
||||
|
||||
self.initialPhotoIndex = initialPhotoIndex;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
-(NSString *)initialPhotoName {
|
||||
return [self.photoArray[self.initialPhotoIndex] photoName];
|
||||
}
|
||||
|
||||
-(NSInteger)initialPhotoIndex {
|
||||
return [self.model.second integerValue];
|
||||
}
|
||||
|
||||
-(NSArray *)photoArray {
|
||||
return self.model.first;
|
||||
return [self.model[self.initialPhotoIndex] photoName];
|
||||
}
|
||||
|
||||
-(FRPPhotoModel *)photoModelAtIndex:(NSInteger)index {
|
||||
if (index < 0 || index > self.photoArray.count - 1) {
|
||||
if (index < 0 || index > self.model.count - 1) {
|
||||
// Index was out of bounds, return nil
|
||||
return nil;
|
||||
} else {
|
||||
return self.photoArray[index];
|
||||
return self.model[index];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user