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 1013349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:05:14+00:00 2026-05-16T10:05:14+00:00

I have a table view and when a user selects a cell I want

  • 0

I have a table view and when a user selects a cell I want to log a unique id. I thought I could use the index but the numbers are not sequential (I.e. 1,4,5,9,etc). Is there a way of defining a custom index or ID for a cell?

So I have the following cells in a table:

dog
cat
fish

the above cells have ids as below

2 dog
4 cat
8 fish

is there a way that when a user touches the fish cell it will return 8?

Indexpath.row would return 2 and I need 8. So is there a custom propertie I can set for each cell?

  • 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-16T10:05:14+00:00Added an answer on May 16, 2026 at 10:05 am

    Not sure I totally understand the problem, but this should be ‘sequential’:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        NSLog(@"%i", indexPath.row);
    }
    

    Update: Ok, so I think I get the confusion.

    You need to have your dog, cat, fish, etc. in an NSArray that looks like [dog, cat, fish] that matches up with what you’re displaying on the screen, or else you’ll never be able to associate the two.

    indexPath.row will be your pointer into that NSArray. So when you hit the second row, that code above will spit out 1. 1 in your array should your cat object, even though that’s not the cat’s id.

    So then you do

    myAnimal = [myArray objectAtIndex:indexPath.row];
    

    to get your object, which in this case would be your cat. myAnimal.id will give you your 2.

    Or, if your animals are dictionaries, it would be

    [myAnimal objectForKey: @"id"]
    

    would give you your 2.

    Hopefully that helps a little more.

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

Sidebar

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.