I want to get device ID in at all classes level in swift which will be included as parameter every time async call made.And I really don't get clearly about Apple Access Control.So,I really need help
So,How to make saving device id at start point and them accessible to all classes for async request?
In app,didFinishLaunchingWithOptions,I will add the following code let say keychain is the library where i store value
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”)
}
And I want to access that private var at everywhere in the UIViewController class.
class ViewController : UIViewController {
let deviceID = //some private var with getter?
}
Is there any idea that i can do in swift?using Apple Access Control?
And that problem is connected to that question : Getting Device ID is not unique
define your deviceID as static and you will be able to access it everywhere
after your code to initiate the keychain, set it as a static at some class
class DeviceArg {
static var deviceId = keychain.get(“deviceID”)
}
// some other place in the code
let check = DeviceArg.deviceId //get deviceId