gpt4 book ai didi

swift 3.0 数据到字符串?

转载 作者:IT王子 更新时间:2023-10-29 04:57:18 26 4
gpt4 key购买 nike

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {}

我想要deviceToken

但是:

let str = String.init(data: deviceToken, encoding: .utf8)

strnil

swift 3.0

如何让 data 变成 string

Registering for Push Notifications in Xcode 8/Swift 3.0?不工作,答案是几个月前,我已经试过了:

enter image description here

并打印:

enter image description here

最佳答案

我是来寻找 Swift 3 Data to String 问题的答案的,但从来没有得到好的答案。经过一番鬼混之后,我想到了这个:

var testString = "This is a test string"
var somedata = testString.data(using: String.Encoding.utf8)
var backToString = String(data: somedata!, encoding: String.Encoding.utf8) as String!

关于swift 3.0 数据到字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39616821/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com