get data select tableview variable swift

Multi tool use
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

add a comment |
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

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
add a comment |
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

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

swift

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
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
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
add a comment |
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
}
}
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.
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
add a comment |
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
add a comment |
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
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
answered 2 days ago
Jay
18.5k42949
18.5k42949
add a comment |
add a comment |
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
}
}
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.
add a comment |
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
}
}
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.
add a comment |
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
}
}
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
}
}
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.
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.
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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