diff --git a/Example/BSImagePicker.xcodeproj/project.pbxproj b/Example/BSImagePicker.xcodeproj/project.pbxproj index 2e2de9bb..aafd7930 100644 --- a/Example/BSImagePicker.xcodeproj/project.pbxproj +++ b/Example/BSImagePicker.xcodeproj/project.pbxproj @@ -272,7 +272,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0710; - LastUpgradeCheck = 0810; + LastUpgradeCheck = 0820; ORGANIZATIONNAME = CocoaPods; TargetAttributes = { 55E273E71BE004F2006006A7 = { diff --git a/Example/BSImagePicker.xcodeproj/xcshareddata/xcschemes/BSImagePicker-Example.xcscheme b/Example/BSImagePicker.xcodeproj/xcshareddata/xcschemes/BSImagePicker-Example.xcscheme index 5b689162..ccff5737 100644 --- a/Example/BSImagePicker.xcodeproj/xcshareddata/xcschemes/BSImagePicker-Example.xcscheme +++ b/Example/BSImagePicker.xcodeproj/xcshareddata/xcschemes/BSImagePicker-Example.xcscheme @@ -1,6 +1,6 @@ Void in -// if let asset = asset as? PHAsset , idx % 2 == 0 { -// evenAssetIds.append(asset.localIdentifier) -// } -// } -// -// let evenAssets = PHAsset.fetchAssets(withLocalIdentifiers: evenAssetIds, options: nil) -// -// let vc = BSImagePickerViewController() -// vc.defaultSelections = evenAssets -// -// bs_presentImagePickerController(vc, animated: true, -// select: { (asset: PHAsset) -> Void in -// print("Selected: \(asset)") -// }, deselect: { (asset: PHAsset) -> Void in -// print("Deselected: \(asset)") -// }, cancel: { (assets: [PHAsset]) -> Void in -// print("Cancel: \(assets)") -// }, finish: { (assets: [PHAsset]) -> Void in -// print("Finish: \(assets)") -// }, completion: nil) + let allAssets = PHAsset.fetchAssets(with: PHAssetMediaType.image, options: nil) + var evenAssetIds = [String]() + + allAssets.enumerateObjects({ (asset, idx, stop) -> Void in + if idx % 2 == 0 { + evenAssetIds.append(asset.localIdentifier) + } + }) + + let evenAssets = PHAsset.fetchAssets(withLocalIdentifiers: evenAssetIds, options: nil) + + let vc = BSImagePickerViewController() + vc.defaultSelections = evenAssets + + bs_presentImagePickerController(vc, animated: true, + select: { (asset: PHAsset) -> Void in + print("Selected: \(asset)") + }, deselect: { (asset: PHAsset) -> Void in + print("Deselected: \(asset)") + }, cancel: { (assets: [PHAsset]) -> Void in + print("Cancel: \(assets)") + }, finish: { (assets: [PHAsset]) -> Void in + print("Finish: \(assets)") + }, completion: nil) } } diff --git a/Pod/Classes/Controller/BSImagePickerViewController.swift b/Pod/Classes/Controller/BSImagePickerViewController.swift index e29c6ebb..0d08a1de 100644 --- a/Pod/Classes/Controller/BSImagePickerViewController.swift +++ b/Pod/Classes/Controller/BSImagePickerViewController.swift @@ -46,12 +46,12 @@ open class BSImagePickerViewController : UINavigationController { /** Default selections */ - private var defaultSelections: PHFetchResult? + open var defaultSelections: PHFetchResult? /** Fetch results. */ - private lazy var fetchResults: [PHFetchResult] = { () -> [PHFetchResult] in + open lazy var fetchResults: [PHFetchResult] = { () -> [PHFetchResult] in let fetchOptions = PHFetchOptions() // Camera roll fetch result