0

I have 2 view controller: AccountViewController and ChangeEmailViewController. The account controller contains the email of the user. The user can change his email by pressing the button titled "change" and will take him to a ChangeEmailViewController. In ChangeEmailViewController, he can write the new email and click on the button titled "submit" to change the email and will show the new email in AccountViewController.(check image to see what I've done in storyboard)

image

My Questions are: 1- How I can connect both view controllers together? 2- How can I show the email of the user in the old email section in ChangeViewController? 3- How can I change the email of user in AccountViewController with the new email that the user will submit when he/she writes it in the textfield of ChangeEmailController and will be the new email in AccountViewController

  • You can get help from this [link](http://stackoverflow.com/questions/19343519/pass-data-back-to-previous-viewcontroller) . How to pass data between view controllers. :) – Amir Khan Apr 02 '17 at 05:18

1 Answers1

0

Here are my answers

  1. How I can connect both view controllers together?
    • You can use delegate. You can connect two viewcontrollers through delegate.
    • You can use NSNotificationCenter.
    • You can set one of them to a property of the other.
  2. How can I show the email of the user in the old email section in ChangeViewController?

    • In general, you can pass the old email value when you call/create ChangeViewController. Perhaps, you will call/create instance of ChangeViewController via segue identification or Xib identification. If you use segue identification, you can pass the value by overriding prepareForSeque. please note: How to pass prepareForSegue: an object

    • If you use Xib identification, you can note below Passing parameter from one xib to another xib

    • You could have another one way. If the value was stored in DB or BackEnd Server, you can get it again in ChangeViewController. Of course, Once you think that it's better way for you.
  3. How can I change the email of....

    • You can use Delegate or NSNotificationCenter.

    When the value is changed, you can use call function through Delegate or send a message via NSNotificationCenter.

Well, if you have another questions, please feel free to contact me.

Thanks.

Community
  • 1
  • 1
ShineMan
  • 354
  • 5
  • 14