Wanglin Luo avatar

iOS11 Write文件时抛出fileWriteUnsupportedScheme异常的处理方案

luowanglin

Published: 07 Mar 2019 › Updated: 07 Mar 2019iOS11 Write文件时抛出fileWriteUnsupportedScheme异常的处理方案

iOS11 Write文件时抛出fileWriteUnsupportedScheme异常的处理方案


iOS11 Write文件时抛出fileWriteUnsupportedScheme异常的处理方案
iOS11的发布,对于开发者来说,又是一个适配的季节。其中从相册获取图片,加入新权限啦,一不注意,又得Crash了☹️,All Right ! NSPhotoLibraryAddUsageDescription 登场了,在iOS11之后NSPhotoLibraryUsageDescription将成为默认权限了,但如果需要存储图片,则要记得在info.plist中加入该权限,如下图:
iOS11 Write文件时抛出fileWriteUnsupportedScheme异常的处理方案
好吧!差点绕开话题了,Swift的throws异常功能很是Big,当然也引出了我遇到的问题,在从图库获取图片后,再进行重命名转存储时,抛异常了“CocoaError.fileWriteUnsupportedScheme”,熟悉Schemed的童靴,我想已经知道原因了😎,但是该添加怎样的URL头才合适呢? 拜托冷静点,我们是可以从UIImagePickerController代理回调方法的info:[String:Any] 参数中获取到URL相关路径信息的,是这样的“file:///private”,Awesome!我们只需要拼接一下即可,但还是的记得加上系统版本判断,毕竟这是iOS11之后才这么干的。完整路径样例如下:
iOS11 Write文件时抛出fileWriteUnsupportedScheme异常的处理方案
iOS11 Write文件时抛出fileWriteUnsupportedScheme异常的处理方案
原文始发于:iOS11 Write文件时抛出fileWriteUnsupportedScheme异常的处理方案


Posted from my blog with SteemPress : http://cnstm.org/blog/2017/12/20/4aa1ec3bf8/

Leave iOS11 Write文件时抛出fileWriteUnsupportedScheme异常的处理方案 to:

Written by

Mobile Application Developer

Read more #steempress posts


Best Posts From Wanglin Luo

We have not curated any of luowanglin's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Wanglin Luo