2016-06-30 13:02:37 +03:00
|
|
|
//
|
|
|
|
// GalleryData.m
|
|
|
|
// ReactNativeCameraKit
|
|
|
|
//
|
|
|
|
// Created by Ran Greenberg on 30/06/2016.
|
|
|
|
// Copyright © 2016 Wix. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "GalleryData.h"
|
|
|
|
|
|
|
|
@interface GalleryData ()
|
|
|
|
|
|
|
|
@property (nonatomic, strong) PHFetchResult *fetchResults;
|
|
|
|
@property (nonatomic, strong, readwrite) NSArray *data;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@implementation GalleryData
|
|
|
|
|
|
|
|
-(instancetype)initWithFetchResults:(PHFetchResult*)fetchResults {
|
|
|
|
|
|
|
|
self = [super init];
|
|
|
|
if (self) {
|
|
|
|
self.fetchResults = fetchResults;
|
|
|
|
self.data = [self arrayWithFetchResults:self.fetchResults];
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-(NSArray*)arrayWithFetchResults:(PHFetchResult*)fetchResults {
|
|
|
|
|
|
|
|
NSMutableArray *array = [[NSMutableArray alloc] init];
|
|
|
|
|
|
|
|
for (PHAsset *asset in fetchResults) {
|
2016-06-30 17:57:34 +03:00
|
|
|
NSMutableDictionary *assetDictionary = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
|
|
|
|
asset, @"asset",
|
|
|
|
[NSNumber numberWithBool:NO], @"isSelected",
|
|
|
|
nil];
|
|
|
|
|
2016-06-30 13:02:37 +03:00
|
|
|
[array addObject:assetDictionary];
|
|
|
|
}
|
|
|
|
|
|
|
|
return array;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@end
|