【发布时间】:2016-06-01 21:30:12
【问题描述】:
我想在 swift 中快速获取所有类级别的设备 ID,每次进行异步调用时都会将其作为参数包含在内。而且我真的不清楚 Apple Access Control。所以,我真的需要帮助
那么,如何在起点保存设备ID,并且所有类都可以访问它们以进行异步请求?
在应用程序中,didFinishLaunchingWithOptions,我将添加以下代码 假设钥匙串是我存储价值的图书馆
if keychain.get("deviceID") == nil{
keychain.set(UIDevice.currentDevice().identifierForVendor!.UUIDString,forKey : ”deviceID”)
//some private var deviceID = keychain.get(“deviceID”)
}
else{
some private var deviceID = keychain.get(“deviceID”)
}
我想在 UIViewController 类的任何地方访问那个私有变量。
class ViewController : UIViewController {
let deviceID = //some private var with getter?
}
有什么想法可以让我快速使用 Apple Access Control 吗?
这个问题与那个问题有关:Getting Device ID is not unique
【问题讨论】: