Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1115611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T03:11:01+00:00 2026-05-17T03:11:01+00:00

I want to populate a TableView with data from a database and, when tap

  • 0

I want to populate a TableView with data from a database and, when tap a cell, in didSelectRowAtIndexPath, sending selected ID to a new View.

I would like to view, in cell text, the description of the record and to put ID in a hidden field/property of the cell, but I could not find a way to do it.
I know I can get an ID from the data source (something like [my_data_source objectAtIndex:indexPath.row]; ) but I don’t really like this way, I would prefer to have an ID assigned to a single cell.

Is there a way to do it?
Thanks in advance and greetings.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T03:11:01+00:00Added an answer on May 17, 2026 at 3:11 am

    I’m guessing you’ve come from web development? I also found it difficult to do it this way, but its the best way. IT probably is possible – but its better if you get used to doing it like this, it really is.

    Basically define an NSArray in the .h file (so the whole script can use it).

    then in the init function:

    // set the array
    myArray = [NSArray arrayWithObjects:@"One",@"Two",@"Threee",nil];
    [myArray retain];
    

    then the table view delegate methods:

    // set numebr of rows
    - (CGFloat)tableView:(UITableView *)tableView numberOfRowsForSection:(NSUInteger)section {
      return [myArray count];
    }
    
    // set the cell titleLabel value
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
      // set the cell - I can't remember the exact code then do:
      cell.textLabel.text = [myArray objectAtIndex:[indexPath row]];
    }
    
    // similarly
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
      NSLog(@"%@",[myArray objectAtIndex:[indexPath row]];
    }
    

    (disclaimer: these are just off the top of my head, and I haven’t checked the exact methods – they’re probably wrong in some way – but the code inside the functions is what you want really.)

    When you’ve started using this you’ll see its so much better than “hiding” an id somewhere in a table. To get things from the database I would suggest adding it all to a dictionary, or an array or similar and doing it like that when you init the class, but if you really want to do it dynamically then pretend your “hidden” ids are just index’s of an array. So id#1 is at index 1 in your array. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to populate data from database in to a table view in grouped
I want to populate my database with test data my user and profile models
I have a view controller that is used to populate data from the core
I want to load tableView values from a database, called for test purposes database.sqlite.
I have a table view that i want to populate with information from xml.
I have a tableview where each cell is populated with dynamic data from an
Actually I want to populate an array to fill up my table view, but
I want to populate a table form a MYSQL database. I have defined the
I want to populate a drop down menu with a column from a MySQL
I want to populate database with Cyrillic text namespace :db do task :populate =>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.