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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:39:00+00:00 2026-05-30T05:39:00+00:00

In my application i have a table view controller that builds a table with

  • 0

In my application i have a table view controller that builds a table with sections from a .plist file. Every cell is unique, as it’s based on ID parameter that is stored for every item in the plist file and cannot repeat. As example of the plist:

<dict>
<key>Section One</key>
<dict>
    <key>Item 0</key>
    <dict>
        <key>name</key>
        <string>Some name one</string>
        <key>picfile</key>
        <string>take8.png</string>
        <key>takeItemId</key>
        <integer>101</integer>
    </dict>
    <key>Item 1</key>
    <dict>
        ...
    </dict>
</dict>
<key>Section Two</key>
<dict>
    <key>Item 0</key>
    <dict>
        <key>name</key>
        <string>Some name two</string>
        <key>picfile</key>
        <string>take6.png</string>
        <key>takeItemId</key>
        <integer>103</integer>
    </dict>
    <key>Item 1</key>....

So my table consists of cells containing a text label (takeItemID), a picture from file and another text label (Name).
Now, i have some event that brings an ID as a string (I receive commands from tcp socket connection). And I want my table to highlight (to change a background) in those cells that contain received ID string as the corresponding text label. Getting NSIndexPath somehow from the plist would be OK as well.

Edit: here below is my TableView:cellForRowAtIndexPath:

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {    
NSUInteger section = [indexPath section];
NSUInteger row = [indexPath row];

NSString *sGroup = [sequencerGroups objectAtIndex:section]; 
NSDictionary *tSection = [sequencer objectForKey:sGroup];  

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SecuencerCell"];

NSString *takeItemName = [[[tSection allKeys] sortedArrayUsingSelector:@selector(compare:)] objectAtIndex:row]; 
NSDictionary *takeItem = [tSection objectForKey:takeItemName]; 

UILabel *idLabel = (UILabel *)[cell viewWithTag:104];
idLabel.text = [NSString stringWithFormat:@"%@",[takeItem valueForKey:@"takeItemId"]];

UILabel *nameLabel = (UILabel *)[cell viewWithTag:102];
nameLabel.text = [takeItem valueForKey:@"name"]; 

UIButton *piconButton = (UIButton *)[cell viewWithTag:101];
UIImage *TakeImage = [UIImage imageNamed:[takeItem valueForKey:@"picfile"]];
[piconButton setBackgroundImage:TakeImage forState:UIControlStateNormal];


UIButton *resumeButton = (UIButton *)[cell viewWithTag:103];    
UIImage *resumeImage = [UIImage imageNamed:@"resume.png"];
[resumeButton setBackgroundImage:resumeImage forState:UIControlStateNormal];



return cell;   
 }

Edit: here is where sequencerGroups and sequencer are taken from:

NSString *path = [documentsDirectory stringByAppendingPathComponent:@"Sequencer.plist"];

NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];
self.sequencer = dict; 
[dict release];

NSArray *array = [sequencer allKeys];

self.sequencerGroups = array;

Thanks a lot,
Maxim

  • 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-30T05:39:01+00:00Added an answer on May 30, 2026 at 5:39 am

    To create an indexPath from a rowNumber you can use: [NSIndexPath indexPathForRow:<#(NSInteger)#> inSection:<#(NSInteger)#>];

    This makes row->indexPath conversion easy, once you have the row & section numbers.

    So your question then becomes – how do I get the row & section numbers from the takeItemId.

    I think the way I would approach it (there are numerous ways you can consider however, depending on how critical the execution time of loading your plist is) would be – right after I parse the plist, I would construct an NSDictionary which maps the takeItemId to an IndexPath.

    An example:

    NSDictionary *myPlist = ...
    NSMutableDictionary *mapKeyToIndexPath = [NSMutableDictionary dictionary];
    NSUInteger section = 0;
    NSUInteger row = 0;
    for (id sectionKey in [myPlist allKeys]) {
        // Parse Sections First
        NSDictionary *section = [myPlist objectForKey:sectionKey];
        for (id rowKey in [section allKeys]) {
            // Parse Rows Next
            NSDictionary *row = [section objectForKey:rowKey];
            NSString *takeItemId = [row objectForKey:@"takeItemId"];
    
            NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row++ inSection:section];
            [mapKeyToIndexPath addObject:indexPath forKey:takeItemId];
        }
        // Move to first row, next section
        row = 0;
        section ++;
    }
    

    Once you have the mapKeyToIndexPath dictionary, you can then grab the correct indexPath when you receive the takeItemId in your Event and pass it to [myTableDataSource tableView:myTableView highlightCellAtIndexPath:indexPath];

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

Sidebar

Related Questions

I have a document-based application with a view controller that contains a table, array
I have an MVC application view that is generating quite a large HTML table
I have a problem in an iPhone application. Application has a table view controller
Hi i'm working on project that have a table view with 10 controllers every
In my Iphone application I am trying to navigate from one table view controller
I have application with following design: Table View that lists documents. And ViewController where
I have an application with navigation controller and some table view controller. In table
I am designing an application in which i have a table view controller. Now
In my iPhone application I have a table view. When user taps any row,
I have table rows of data in html being filled from a CGI application.

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.