I have a storyboard which start with a login page. And I have a User class like this
class User {
// Properties
var firmCode : String
var firmId : String
var userId : String
// Default Initializer
init() {
self.firmCode = ""
self.firmId = ""
self.userId = ""
}
// Defult Initializer with prams
init(firmCode: String, firmId: String, userId: String) {
self.firmCode = firmCode
self.firmId = firmId
self.userId = userId
}
}
I am generating some values in login page, and I can create my User object with these values.
Now I want to make this object global and use this user object in all scene.
How to pass this object to other scenes? For example I want to pass this values with my object to an embed static table view controller like this
Note: Does it matter, the embed controller has a tab bar controller? I guess I need to use my delegate file?
EDIT:
Now I have created my global object like this:
// test value
let firmId = "Company Id"
// Creating user object without user class declaration
NSUserDefaults.standardUserDefaults().setObject(firmId, forKey: "testFirmId")
And trying to get my object like this:
// Creating user variable in other scene by globally
let getValue : AnyObject? = NSUserDefaults.standardUserDefaults().objectForKey("testFirmId")
// checking
println(getValue!)
AND done, return my value on termanal. All work until here.
But now the value return to me as AnyObject, I need the convert it String to apply like this:
someLabel.text = getValue!