get data select tableview variable swift

Multi tool use
Multi tool use












0














How can I retrieve the id number of the data that I selected in tableview? I want to draw the id number of the data I selected in the tableview in the application as it appears in the photo. 2> titles> id rankings this way. I want to get the id number when I click on the name. for example, I want to draw the id number of this data when I press bb.enter image description here










share|improve this question






















  • Create a model for id and title and render it in tableview then you can easily get particular data using indexPath.row.
    – Abhishek Jadhav
    Dec 27 at 13:07
















0














How can I retrieve the id number of the data that I selected in tableview? I want to draw the id number of the data I selected in the tableview in the application as it appears in the photo. 2> titles> id rankings this way. I want to get the id number when I click on the name. for example, I want to draw the id number of this data when I press bb.enter image description here










share|improve this question






















  • Create a model for id and title and render it in tableview then you can easily get particular data using indexPath.row.
    – Abhishek Jadhav
    Dec 27 at 13:07














0












0








0







How can I retrieve the id number of the data that I selected in tableview? I want to draw the id number of the data I selected in the tableview in the application as it appears in the photo. 2> titles> id rankings this way. I want to get the id number when I click on the name. for example, I want to draw the id number of this data when I press bb.enter image description here










share|improve this question













How can I retrieve the id number of the data that I selected in tableview? I want to draw the id number of the data I selected in the tableview in the application as it appears in the photo. 2> titles> id rankings this way. I want to get the id number when I click on the name. for example, I want to draw the id number of this data when I press bb.enter image description here







swift firebase






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 27 at 13:05









berko berko

1




1












  • Create a model for id and title and render it in tableview then you can easily get particular data using indexPath.row.
    – Abhishek Jadhav
    Dec 27 at 13:07


















  • Create a model for id and title and render it in tableview then you can easily get particular data using indexPath.row.
    – Abhishek Jadhav
    Dec 27 at 13:07
















Create a model for id and title and render it in tableview then you can easily get particular data using indexPath.row.
– Abhishek Jadhav
Dec 27 at 13:07




Create a model for id and title and render it in tableview then you can easily get particular data using indexPath.row.
– Abhishek Jadhav
Dec 27 at 13:07












2 Answers
2






active

oldest

votes


















1














First off, your Firebase structure should probably be simplified and please don't use arrays. Best practice is to create your keys with .childByAutoId.



titles
child_by_auto_id_0
title: "bb"
child_by_auto_id_1
title: "cc"


Then, when you read in your firebase nodes, populate a class, and then store those class objects in a class array



class ViewController: UIViewController {
var myTitleArray: [TitleClass]()

class TitleClass {
var id = ""
var title = ""
}

func readFirebaseData() {
//read firebase, iterate over results and populate array

let title = TitleClass()
title.id = snapshot.key //this will be the childByAutoId for each node
title.title = //get the title from the snapshot
self.myTitleArray.append(title)

//when done iterating and populating the array, tableView .reloadData()
}


and in your tableView delegate methods, use the self.myTitleArray as your dataSource






share|improve this answer





























    0














    Probably you have an array or something similar to fill the tableview, then you have to implement de delegate func which is in charge to alert when user clicks in a row.
    I have took this from another post, but you basically



    class ViewController : UITableViewController {

    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    let selectedItem = items.objectAtIndex(indexPath.row) as YourObject
    selectedItem.id
    }
    }





    share|improve this answer








    New contributor




    Camilo Lopez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.


















      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%2f53945591%2fget-data-select-tableview-variable-swift%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      First off, your Firebase structure should probably be simplified and please don't use arrays. Best practice is to create your keys with .childByAutoId.



      titles
      child_by_auto_id_0
      title: "bb"
      child_by_auto_id_1
      title: "cc"


      Then, when you read in your firebase nodes, populate a class, and then store those class objects in a class array



      class ViewController: UIViewController {
      var myTitleArray: [TitleClass]()

      class TitleClass {
      var id = ""
      var title = ""
      }

      func readFirebaseData() {
      //read firebase, iterate over results and populate array

      let title = TitleClass()
      title.id = snapshot.key //this will be the childByAutoId for each node
      title.title = //get the title from the snapshot
      self.myTitleArray.append(title)

      //when done iterating and populating the array, tableView .reloadData()
      }


      and in your tableView delegate methods, use the self.myTitleArray as your dataSource






      share|improve this answer


























        1














        First off, your Firebase structure should probably be simplified and please don't use arrays. Best practice is to create your keys with .childByAutoId.



        titles
        child_by_auto_id_0
        title: "bb"
        child_by_auto_id_1
        title: "cc"


        Then, when you read in your firebase nodes, populate a class, and then store those class objects in a class array



        class ViewController: UIViewController {
        var myTitleArray: [TitleClass]()

        class TitleClass {
        var id = ""
        var title = ""
        }

        func readFirebaseData() {
        //read firebase, iterate over results and populate array

        let title = TitleClass()
        title.id = snapshot.key //this will be the childByAutoId for each node
        title.title = //get the title from the snapshot
        self.myTitleArray.append(title)

        //when done iterating and populating the array, tableView .reloadData()
        }


        and in your tableView delegate methods, use the self.myTitleArray as your dataSource






        share|improve this answer
























          1












          1








          1






          First off, your Firebase structure should probably be simplified and please don't use arrays. Best practice is to create your keys with .childByAutoId.



          titles
          child_by_auto_id_0
          title: "bb"
          child_by_auto_id_1
          title: "cc"


          Then, when you read in your firebase nodes, populate a class, and then store those class objects in a class array



          class ViewController: UIViewController {
          var myTitleArray: [TitleClass]()

          class TitleClass {
          var id = ""
          var title = ""
          }

          func readFirebaseData() {
          //read firebase, iterate over results and populate array

          let title = TitleClass()
          title.id = snapshot.key //this will be the childByAutoId for each node
          title.title = //get the title from the snapshot
          self.myTitleArray.append(title)

          //when done iterating and populating the array, tableView .reloadData()
          }


          and in your tableView delegate methods, use the self.myTitleArray as your dataSource






          share|improve this answer












          First off, your Firebase structure should probably be simplified and please don't use arrays. Best practice is to create your keys with .childByAutoId.



          titles
          child_by_auto_id_0
          title: "bb"
          child_by_auto_id_1
          title: "cc"


          Then, when you read in your firebase nodes, populate a class, and then store those class objects in a class array



          class ViewController: UIViewController {
          var myTitleArray: [TitleClass]()

          class TitleClass {
          var id = ""
          var title = ""
          }

          func readFirebaseData() {
          //read firebase, iterate over results and populate array

          let title = TitleClass()
          title.id = snapshot.key //this will be the childByAutoId for each node
          title.title = //get the title from the snapshot
          self.myTitleArray.append(title)

          //when done iterating and populating the array, tableView .reloadData()
          }


          and in your tableView delegate methods, use the self.myTitleArray as your dataSource







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 2 days ago









          Jay

          18.5k42949




          18.5k42949

























              0














              Probably you have an array or something similar to fill the tableview, then you have to implement de delegate func which is in charge to alert when user clicks in a row.
              I have took this from another post, but you basically



              class ViewController : UITableViewController {

              func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
              let selectedItem = items.objectAtIndex(indexPath.row) as YourObject
              selectedItem.id
              }
              }





              share|improve this answer








              New contributor




              Camilo Lopez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.























                0














                Probably you have an array or something similar to fill the tableview, then you have to implement de delegate func which is in charge to alert when user clicks in a row.
                I have took this from another post, but you basically



                class ViewController : UITableViewController {

                func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
                let selectedItem = items.objectAtIndex(indexPath.row) as YourObject
                selectedItem.id
                }
                }





                share|improve this answer








                New contributor




                Camilo Lopez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.





















                  0












                  0








                  0






                  Probably you have an array or something similar to fill the tableview, then you have to implement de delegate func which is in charge to alert when user clicks in a row.
                  I have took this from another post, but you basically



                  class ViewController : UITableViewController {

                  func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
                  let selectedItem = items.objectAtIndex(indexPath.row) as YourObject
                  selectedItem.id
                  }
                  }





                  share|improve this answer








                  New contributor




                  Camilo Lopez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  Probably you have an array or something similar to fill the tableview, then you have to implement de delegate func which is in charge to alert when user clicks in a row.
                  I have took this from another post, but you basically



                  class ViewController : UITableViewController {

                  func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
                  let selectedItem = items.objectAtIndex(indexPath.row) as YourObject
                  selectedItem.id
                  }
                  }






                  share|improve this answer








                  New contributor




                  Camilo Lopez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  share|improve this answer



                  share|improve this answer






                  New contributor




                  Camilo Lopez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  answered 2 days ago









                  Camilo Lopez

                  112




                  112




                  New contributor




                  Camilo Lopez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.





                  New contributor





                  Camilo Lopez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






                  Camilo Lopez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






























                      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.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • 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%2f53945591%2fget-data-select-tableview-variable-swift%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







                      vo5Ymenm5XP2A MghxT2Tu0tvVm,yGgb,D,RnNu4L gEV
                      1Tnkw0gUElR4ZZUsDRCerwitEbKiu1rE5YYMrtvVbyVA6bTDRRH1,Iy5mxvJX7sLCY E2DiUrRSjC Zk,Ixp20HyEPyDCIkUf u Af

                      Popular posts from this blog

                      Monofisismo

                      Angular Downloading a file using contenturl with Basic Authentication

                      Olmecas