小编rac*_*rma的帖子

如何将Base64数据和NSData转换为字符串

我是 IOS 的新手,我正在制作一个项目,在该项目中我从 Web 服务接收 Base64 数据。如何将 Base64 数据转换为字符串以及如何在 swift 中打开 pdf 视图,并检查 iPhone 中是否安装了任何 pdf 所有者应用程序。我想知道如何在字符串 swift 中转换 NSDATA。帮我举例,例如这是Base64数据JVBERi0xLjQKJcfsj6IKNSAwIG9iago8PC9MZW5ndGggNiAwIFIvRmlsdGVyIC9GbGF0ZURlY29kZT4+CnN0cmVhbQp4nLVcza8ct5GH1rK9ejIU24lkO5GtJ8vWm5E87eY3uXtbYLHAYi8 JdItySrABAjhA8v8fUuwmu35kF2fmxbsWDMxjk8VisapYX+TfbudJ6ds5/6s//vj

就像这样 nsdata <25504446 2d312e34 0a25c7ec 8fa20a35 2030206f 626a0a3c 3c2f4c65 6e677468 20362030 20522f46 696c7465 72202f46 6c617465 44 65636f 64653e3e 0a737472 65616d0a 789cb55c cdaf1cb7 9187d6b2 bd7a3214 db89643b 91ad27cb d69b913c

base64 nsdata ios pdf-viewer swift

4
推荐指数
1
解决办法
7781
查看次数

如何在swift 3中转换xml和json数据

我是 IOS 新手,我想使用 swift 3 将从 SOAP Web 服务接收的一些混合数据(xml 和 JSON 混合数据)转换为数组。我在解析器方法的字符串变量中接收这些数据。

func connection(_ connection: NSURLConnection, didFailWithError error: Error){
    print("\(error)")
    print("Some error in your Connection. Please try again.")
    let alert = UIAlertController(title: "Error", message: "No internet connection", preferredStyle: UIAlertControllerStyle.alert)

    // add an action (button)
    alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))

    self.present(alert, animated: true, completion: nil)
}

func connectionDidFinishLoading(_ connection: NSURLConnection){

    print("Received \(UInt(webResponseData.count)) Bytes")
    // let theXML = String(webResponseData.mutableBytes, length: webResponseData.length, encoding: String.Encoding.utf8)
    let theXML =  XMLParser(data: webResponseData)
    theXML.delegate = self …
Run Code Online (Sandbox Code Playgroud)

xml json web-services swift

3
推荐指数
1
解决办法
7415
查看次数

标签 统计

swift ×2

base64 ×1

ios ×1

json ×1

nsdata ×1

pdf-viewer ×1

web-services ×1

xml ×1