我有一个func,我想返回一个配置的UIDocumentInteractionController
。处理可能无返回func?
问题是,如果我不能构建文档URL,我想返回,但不能像func需要返回查看器。我怎样才能使FUNC返回观众如果URL是有效的,或者如果它不存在编辑此功能...
func saveBase64StringToPDF(base64String: String, title: String) -> UIDocumentInteractionController {
guard var documentsURL = (FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)).last,
let convertedData = Data(base64Encoded: base64String)
else {
return // issue is here
}
documentsURL.appendPathComponent(title)
do {
try convertedData.write(to: documentsURL)
} catch {
print("FAILED TO WRITE")
}
let interactionController = UIDocumentInteractionController(url: documentsURL)
return interactionController
}
只是作为func saveBase64StringToPDF(base64String:String,title:String) - > UIDocumentInteractionController? –