ios - Set value to a UILabel in another UIView Controller in SWIFT -


in app have implemented facebook user login , email user login.

enter image description here

and in app there slide out sidebar.

enter image description here

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

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -