为什么循环添加图片到相册,添加的都是同一张图片
var assetIDs: [String] = []
PHPhotoLibrary.shared().performChanges({
images.forEach { image in
let request = PHAssetCreationRequest.creationRequestForAsset(from: image)
assetIDs.append(request.placeholderForCreatedAsset!.localIdentifier)
}
}) { success, error in
guard success else { return }
let assets = PHAsset.fetchAssets(withLocalIdentifiers: assetIDs, options: nil)
PHPhotoLibrary.shared().performChanges({
let request = PHAssetCollectionChangeRequest()
request.addAssets(assets)
})
}