From cfd53ac6cab79f5519e3262343d5d323e32592db Mon Sep 17 00:00:00 2001 From: Dallas Edwards Date: Thu, 29 Dec 2016 11:44:12 -0500 Subject: [PATCH 1/2] Changed access modifier of fetchResults I changed the access modifier of the fetchResults property from private to open. The documentation mentions using this property in the Custom Fetch Results section. --- Pod/Classes/Controller/BSImagePickerViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pod/Classes/Controller/BSImagePickerViewController.swift b/Pod/Classes/Controller/BSImagePickerViewController.swift index e29c6ebb..7514595b 100644 --- a/Pod/Classes/Controller/BSImagePickerViewController.swift +++ b/Pod/Classes/Controller/BSImagePickerViewController.swift @@ -51,7 +51,7 @@ open class BSImagePickerViewController : UINavigationController { /** Fetch results. */ - private lazy var fetchResults: [PHFetchResult] = { () -> [PHFetchResult] in + open lazy var fetchResults: [PHFetchResult] = { () -> [PHFetchResult] in let fetchOptions = PHFetchOptions() // Camera roll fetch result From 28b8002313455d82b7b6e9d7fd78993a07b1b4e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Gyllstr=C3=B6m?= Date: Sat, 7 Jan 2017 20:07:40 +0100 Subject: [PATCH 2/2] Enabled example code for custom selections --- .../BSImagePicker.xcodeproj/project.pbxproj | 2 +- .../xcschemes/BSImagePicker-Example.xcscheme | 2 +- Example/BSImagePicker/ViewController.swift | 49 +++++++++---------- .../BSImagePickerViewController.swift | 2 +- 4 files changed, 27 insertions(+), 28 deletions(-) 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 7514595b..0d08a1de 100644 --- a/Pod/Classes/Controller/BSImagePickerViewController.swift +++ b/Pod/Classes/Controller/BSImagePickerViewController.swift @@ -46,7 +46,7 @@ open class BSImagePickerViewController : UINavigationController { /** Default selections */ - private var defaultSelections: PHFetchResult? + open var defaultSelections: PHFetchResult? /** Fetch results.