-1

enter image description hereLogin to the page using email id and password and then i want to send data from login page to profile page, but my profile page is linked with the SWrevealviewcontroller as of to show side menu. I am trying using default values. Login View controller]2 form which i want to send data to profile view controller. profile view controller[![][2]]4 Any suggestions what should i do?

Thank you!

2 Answers2

0

You can make use of userDefaults, eg in LoginViewController save data to be used, as done below:

UserDefault.standard.setValue(name, forKey: "User_name")
UserDefault.standard.synchronize()

To use saved data on profile screen:

if let userName = UserDefault.standard.value(forKey: "User_name") as? String {
   self.lblUserName.text = userName
}

Hope this helps out somehow.

koen
  • 5,383
  • 7
  • 50
  • 89
-1

One way to do this could just be using a global variable. A variable is made global if you put it above the class declaration. Example:

var globalInt = 7

class example....{
    // blah blah blah, class code here
}

By doing this, if you change the variable in one screen, if another screen tries to access it after it has been modified, it will access the modified version. So for example if I were to change globalInt to 9 inside the class example, if I then accessed globalInt on another screen, it would be 9. Also, you can modify and access a global variable the same as if you were accessing any variable within the class.

Andy Lebowitz
  • 1,471
  • 2
  • 16
  • 23