BSImagePicker icon indicating copy to clipboard operation
BSImagePicker copied to clipboard

Defer accessing fetchResults settings

Open natecraft1 opened this issue 5 years ago • 1 comments

Issue

Setting custom fetchResults prior to obtaining Photos permission from the user results in null AssetCollections, and thus will present an empty ImagePickerController the first time it is presented.

For instance

let imagePickerVC = ImagePickerController()
imagePickerVC.settings.fetch.album.fetchResults = [PHAssetCollection.fetchAssetCollection(with: .album, subtype: .albumRegular, options: PHFetchOptions())]
imagePickerVC.presentImagePicker(...

will have the effect of presenting an empty picker the first time after permissions are first granted.

Proposed solution Defer the access of the fetchResults settings by using a function rather than a var.

Note There are other ways of solving this, such as adding an onAuthorization closure to the presentImagePicker call and allowing settings to be passed in there.

natecraft1 avatar Dec 03 '20 05:12 natecraft1

Sure makes sense. Wouldn't some of the examples also need to be updated?

mikaoj avatar Dec 19 '21 16:12 mikaoj