Error when trying to save a captured image in swift

风流意气都作罢 提交于 2019-12-02 05:13:47

The problem is that you have never given self.assetCollection or self.photoAsset any value, so they are nil. Thus, when you try to use them in your PHAssetCollectionChangeRequest initializer, you crash.

By the way, if all you want to do is save the image into the camera roll, you don't need all that code. The creation request alone is all you need.

Or, if you want to save the image into the camera roll and into an album, you don't need to call PHAssetCollectionChangeRequest(forAssetCollection:assets:) to do it.

Finally, you really shouldn't have all that extra stuff in the change block. Just do the change and no more. The other stuff should be in the completion block.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!