Ado
Ado

Reputation: 199

Code 3300 error while trying to save a photo to iOS album

While trying to save a photo to a custom album on some devices we get the following error:

The operation couldn’t be completed. (PHPhotosErrorDomain error 3300).

code: 3300

This is the part of the code where the issue happens

PHPhotoLibrary.shared().performChanges({
                let assetChangeRequest = PHAssetChangeRequest.creationRequestForAsset(from: image)
                guard let placeholder = assetChangeRequest.placeholderForCreatedAsset else { return }
                let albumChangeRequest = PHAssetCollectionChangeRequest(for: album)
                albumChangeRequest?.addAssets([placeholder] as NSArray)
            }, completionHandler: { success, error in
                completion(success, error)
            })

I would be thankful for any tips since I am out of ideas.

Upvotes: 3

Views: 3246

Answers (2)

PhuocLuong
PhuocLuong

Reputation: 739

Please try:

let _image = image.pngData()
let assetChangeRequest = PHAssetChangeRequest.creationRequestForAsset(from: _image)
            

Upvotes: 0

Elevo
Elevo

Reputation: 1041

@available(iOS 8, *)

open func addAssets(_ assets: NSFastEnumeration)

have a try albumChangeRequest.addAssets([placeholder] as NSFastEnumeration)


here is the Apple Document

Upvotes: 0

Related Questions