ios - PHPhotoLibrary error: content editing in performChanges results in error "The operation couldn’t be completed. (Cocoa error -1.)" -


this code run on viewdidappear of brand new swift app. info.plist setup correctly privacy - photo library usage description key.

the error the operation couldn’t completed. (cocoa error -1.)

i can create new assets, delete assets, favorite assets, , revert assets... attempting edit content results in error. i've been attempting scour internet clue how go solving (stack overflow, wwdc videos, second page of google, bing , yahoo).

phphotolibrary.requestauthorization { (status:phauthorizationstatus) in      if status != phauthorizationstatus.authorized { return }      let results = phasset.fetchassets(with: nil)     guard let asset = results.firstobject else { return }      if asset.canperform(.content) {          let inputoptions = phcontenteditinginputrequestoptions()         inputoptions.isnetworkaccessallowed = true         inputoptions.canhandleadjustmentdata = { (asjustmentdata) -> bool in             return false         }          asset.requestcontenteditinginput(with: inputoptions, completionhandler: { (input, info) in             guard let input = input else { return }              guard let inputimageurl = input.fullsizeimageurl,             let inputimage = ciimage(contentsof: inputimageurl) else { return }                  guard let eagle = eaglcontext(api: .opengles2) else { return }             let context = cicontext(eaglcontext: eagle)             guard let outputimageref = context.createcgimage(inputimage, from: inputimage.extent) else { return }             let outputimage = uiimage(cgimage: outputimageref, scale: 1.0, orientation: .right)              let output = phcontenteditingoutput(contenteditinginput: input)              guard let imagedata = uiimagejpegrepresentation(outputimage, 0.9) else { return }                 try! imagedata.write(to: output.renderedcontenturl, options: .atomic)              output.adjustmentdata = phadjustmentdata(formatidentifier: "myformat", formatversion: "1.0", data: data())              dispatchqueue.main.async {                 phphotolibrary.shared().performchanges({                      let request = phassetchangerequest(for: asset)                     request.contenteditingoutput = output                  }, completionhandler: { (success, error) in                     print(success ? "it worked" : "it failed error:")                     print(error?.localizeddescription ?? "no errors!")                 })             }         })     } } 

note on revert, ios "do want edit" dialog appears, code above no dialog appears , app doesn't crash.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -