ios - Set value to a UILabel in another UIView Controller in SWIFT -
in app have implemented facebook user login , email user login.
and in app there slide out sidebar.
so email user login working without error. i want set menu's user name name i've got logged in user. in facebook user login i've done using facebook sdk.
so how set value uilable in uiview controller?
you can post notification once have user name:
let userinfo: [string:anyobject] = [ "username": "john"] nsnotificationcenter.defaultcenter().postnotificationname("logged", object: userinfo)
and add observer view controller want load loggedusername:
override func viewdidload() { super.viewdidload() nsnotificationcenter.defaultcenter().addobserver(self, selector: "setname:", name: "logged", object: nil) } func setname(notification: nsnotification) { if let userinfo = notification.object as? [string:anyobject] { if let loggedusername = userinfo["username"] as? string { println(loggedusername) yourlabel.text = loggedusername } } }
Comments
Post a Comment