(Swift) how to use Segue pass textField to TableViewCell under another ViewController?










1















I wonder how to pass the textField to my customTableViweCell. Please, someone help me! enter image description here



override func prepare(for segue: UIStoryboardSegue, sender: Any?) 
if segue.identifier == "segue"
let nextVC = segue.destination as! UINavigationController
let dest = nextVC.topViewController as! ViewController
let ind = sender as! customTableViewCell

let nTxt = nameTxt.text?.description
let pTxt = phoneTxt.text?.description
let eTxt = emailTxt.text?.description
let dTxt = dobTxt.text?.description
ind.lb1 = "(nTxt!)"
ind.lb2 = "(pTxt!)"
ind.lb3 = "(eTxt!)"
ind.lb4 = "(dTxt!)"











share|improve this question


























    1















    I wonder how to pass the textField to my customTableViweCell. Please, someone help me! enter image description here



    override func prepare(for segue: UIStoryboardSegue, sender: Any?) 
    if segue.identifier == "segue"
    let nextVC = segue.destination as! UINavigationController
    let dest = nextVC.topViewController as! ViewController
    let ind = sender as! customTableViewCell

    let nTxt = nameTxt.text?.description
    let pTxt = phoneTxt.text?.description
    let eTxt = emailTxt.text?.description
    let dTxt = dobTxt.text?.description
    ind.lb1 = "(nTxt!)"
    ind.lb2 = "(pTxt!)"
    ind.lb3 = "(eTxt!)"
    ind.lb4 = "(dTxt!)"











    share|improve this question
























      1












      1








      1








      I wonder how to pass the textField to my customTableViweCell. Please, someone help me! enter image description here



      override func prepare(for segue: UIStoryboardSegue, sender: Any?) 
      if segue.identifier == "segue"
      let nextVC = segue.destination as! UINavigationController
      let dest = nextVC.topViewController as! ViewController
      let ind = sender as! customTableViewCell

      let nTxt = nameTxt.text?.description
      let pTxt = phoneTxt.text?.description
      let eTxt = emailTxt.text?.description
      let dTxt = dobTxt.text?.description
      ind.lb1 = "(nTxt!)"
      ind.lb2 = "(pTxt!)"
      ind.lb3 = "(eTxt!)"
      ind.lb4 = "(dTxt!)"











      share|improve this question














      I wonder how to pass the textField to my customTableViweCell. Please, someone help me! enter image description here



      override func prepare(for segue: UIStoryboardSegue, sender: Any?) 
      if segue.identifier == "segue"
      let nextVC = segue.destination as! UINavigationController
      let dest = nextVC.topViewController as! ViewController
      let ind = sender as! customTableViewCell

      let nTxt = nameTxt.text?.description
      let pTxt = phoneTxt.text?.description
      let eTxt = emailTxt.text?.description
      let dTxt = dobTxt.text?.description
      ind.lb1 = "(nTxt!)"
      ind.lb2 = "(pTxt!)"
      ind.lb3 = "(eTxt!)"
      ind.lb4 = "(dTxt!)"








      swift uitableview






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 12 '18 at 21:12









      Ken LeeKen Lee

      62




      62






















          1 Answer
          1






          active

          oldest

          votes


















          0














          segue.destination will contain the destination view controller. You should cast it to your custom view controller that will be presented. That view controller, should have properties defined that will be used to build that view. You should set those properties in prepare so that when the destination view controller loads the view, those properties can be used to update the view components. Here's an example.



          override func prepare(for segue: UIStoryboardSegue, sender: Any?) 
          if segue.identifier == "segue"
          let dest = segue.destination as? YourCustomViewController
          dest?.customProp = someValue







          share|improve this answer























          • let dest = segue.destination as? YourCustomViewController dest?.lb1 = "(nTxt)" error="Value of type 'ViewController' has no member 'lb1'. " the value 'lb1' I have drop under "customerTableViewCell", and "customerTableViewCell" is under "ViewCotroller" how I link it?

            – Ken Lee
            Nov 12 '18 at 21:30











          • lb1 has to be a non-private member of your custom view controller class.

            – ODYN-Kon
            Nov 12 '18 at 21:39











          • lb1 I have drop it to customerTableViewCell, it is not a view controller class. do you have any Idea? how to pass the textField to customTableViewCell

            – Ken Lee
            Nov 13 '18 at 4:29










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53270195%2fswift-how-to-use-segue-pass-textfield-to-tableviewcell-under-another-viewcontr%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          segue.destination will contain the destination view controller. You should cast it to your custom view controller that will be presented. That view controller, should have properties defined that will be used to build that view. You should set those properties in prepare so that when the destination view controller loads the view, those properties can be used to update the view components. Here's an example.



          override func prepare(for segue: UIStoryboardSegue, sender: Any?) 
          if segue.identifier == "segue"
          let dest = segue.destination as? YourCustomViewController
          dest?.customProp = someValue







          share|improve this answer























          • let dest = segue.destination as? YourCustomViewController dest?.lb1 = "(nTxt)" error="Value of type 'ViewController' has no member 'lb1'. " the value 'lb1' I have drop under "customerTableViewCell", and "customerTableViewCell" is under "ViewCotroller" how I link it?

            – Ken Lee
            Nov 12 '18 at 21:30











          • lb1 has to be a non-private member of your custom view controller class.

            – ODYN-Kon
            Nov 12 '18 at 21:39











          • lb1 I have drop it to customerTableViewCell, it is not a view controller class. do you have any Idea? how to pass the textField to customTableViewCell

            – Ken Lee
            Nov 13 '18 at 4:29















          0














          segue.destination will contain the destination view controller. You should cast it to your custom view controller that will be presented. That view controller, should have properties defined that will be used to build that view. You should set those properties in prepare so that when the destination view controller loads the view, those properties can be used to update the view components. Here's an example.



          override func prepare(for segue: UIStoryboardSegue, sender: Any?) 
          if segue.identifier == "segue"
          let dest = segue.destination as? YourCustomViewController
          dest?.customProp = someValue







          share|improve this answer























          • let dest = segue.destination as? YourCustomViewController dest?.lb1 = "(nTxt)" error="Value of type 'ViewController' has no member 'lb1'. " the value 'lb1' I have drop under "customerTableViewCell", and "customerTableViewCell" is under "ViewCotroller" how I link it?

            – Ken Lee
            Nov 12 '18 at 21:30











          • lb1 has to be a non-private member of your custom view controller class.

            – ODYN-Kon
            Nov 12 '18 at 21:39











          • lb1 I have drop it to customerTableViewCell, it is not a view controller class. do you have any Idea? how to pass the textField to customTableViewCell

            – Ken Lee
            Nov 13 '18 at 4:29













          0












          0








          0







          segue.destination will contain the destination view controller. You should cast it to your custom view controller that will be presented. That view controller, should have properties defined that will be used to build that view. You should set those properties in prepare so that when the destination view controller loads the view, those properties can be used to update the view components. Here's an example.



          override func prepare(for segue: UIStoryboardSegue, sender: Any?) 
          if segue.identifier == "segue"
          let dest = segue.destination as? YourCustomViewController
          dest?.customProp = someValue







          share|improve this answer













          segue.destination will contain the destination view controller. You should cast it to your custom view controller that will be presented. That view controller, should have properties defined that will be used to build that view. You should set those properties in prepare so that when the destination view controller loads the view, those properties can be used to update the view components. Here's an example.



          override func prepare(for segue: UIStoryboardSegue, sender: Any?) 
          if segue.identifier == "segue"
          let dest = segue.destination as? YourCustomViewController
          dest?.customProp = someValue








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 12 '18 at 21:16









          ODYN-KonODYN-Kon

          2,1291825




          2,1291825












          • let dest = segue.destination as? YourCustomViewController dest?.lb1 = "(nTxt)" error="Value of type 'ViewController' has no member 'lb1'. " the value 'lb1' I have drop under "customerTableViewCell", and "customerTableViewCell" is under "ViewCotroller" how I link it?

            – Ken Lee
            Nov 12 '18 at 21:30











          • lb1 has to be a non-private member of your custom view controller class.

            – ODYN-Kon
            Nov 12 '18 at 21:39











          • lb1 I have drop it to customerTableViewCell, it is not a view controller class. do you have any Idea? how to pass the textField to customTableViewCell

            – Ken Lee
            Nov 13 '18 at 4:29

















          • let dest = segue.destination as? YourCustomViewController dest?.lb1 = "(nTxt)" error="Value of type 'ViewController' has no member 'lb1'. " the value 'lb1' I have drop under "customerTableViewCell", and "customerTableViewCell" is under "ViewCotroller" how I link it?

            – Ken Lee
            Nov 12 '18 at 21:30











          • lb1 has to be a non-private member of your custom view controller class.

            – ODYN-Kon
            Nov 12 '18 at 21:39











          • lb1 I have drop it to customerTableViewCell, it is not a view controller class. do you have any Idea? how to pass the textField to customTableViewCell

            – Ken Lee
            Nov 13 '18 at 4:29
















          let dest = segue.destination as? YourCustomViewController dest?.lb1 = "(nTxt)" error="Value of type 'ViewController' has no member 'lb1'. " the value 'lb1' I have drop under "customerTableViewCell", and "customerTableViewCell" is under "ViewCotroller" how I link it?

          – Ken Lee
          Nov 12 '18 at 21:30





          let dest = segue.destination as? YourCustomViewController dest?.lb1 = "(nTxt)" error="Value of type 'ViewController' has no member 'lb1'. " the value 'lb1' I have drop under "customerTableViewCell", and "customerTableViewCell" is under "ViewCotroller" how I link it?

          – Ken Lee
          Nov 12 '18 at 21:30













          lb1 has to be a non-private member of your custom view controller class.

          – ODYN-Kon
          Nov 12 '18 at 21:39





          lb1 has to be a non-private member of your custom view controller class.

          – ODYN-Kon
          Nov 12 '18 at 21:39













          lb1 I have drop it to customerTableViewCell, it is not a view controller class. do you have any Idea? how to pass the textField to customTableViewCell

          – Ken Lee
          Nov 13 '18 at 4:29





          lb1 I have drop it to customerTableViewCell, it is not a view controller class. do you have any Idea? how to pass the textField to customTableViewCell

          – Ken Lee
          Nov 13 '18 at 4:29

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53270195%2fswift-how-to-use-segue-pass-textfield-to-tableviewcell-under-another-viewcontr%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Use pre created SQLite database for Android project in kotlin

          Darth Vader #20

          Ondo