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

  • SEARCH
  • Home
  • 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 6766341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:49:08+00:00 2026-05-26T14:49:08+00:00

I have multiple objects, each with a series of attributes. I’d like the user

  • 0

I have multiple objects, each with a series of attributes. I’d like the user to select two objects and then the app will display a comparison of the respective object’s attributes. I’m having difficulty deciding how best to select the two objects. I would use a UITableView, but how to select two cells before proceeding? Alternatively, I could display UIButtons, but again, how best to select two before proceeding? Perhaps there is another way that isnt occuring to me.

Ideas appreciated.

  • 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-26T14:49:09+00:00Added an answer on May 26, 2026 at 2:49 pm

    Make sure your tableView allows selections:

    myTableView.allowsSelection = YES;

    Define two properties two store the first and second selection index paths:

    @property (nonatomic, retain) NSIndexPath *firstSelection;
    @property (nonatomic, retain) NSIndexPath *secondSelection;
    

    Set the selection whenever the user selects a row. In this example, I use FIFO approach to the selections. In addition, if there are two selections already made, show the object attributes:

    - (void)tableView:(UITableView *)tableView 
                       didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
       // push the selections up each time. The selected items will always be the
       // last two selections
       self.firstSelection = self.secondSelection;
       self.secondSelection = indexPath;
    
       // if both selections are not nil, two selections have been made.
       if (self.firstSelection && self.secondSelection)
          [self showComparisonOfObject:self.firstSelection
                            withObject:self.secondSelection];
    }
    

    Finally, use a checkmark accessory on the selected rows:

    - (UITableViewCell *)tableView:(UITableView *)tableView 
             cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
       static NSString *CellIdentifier = @"Cell";
       UITableViewCell *cell = 
                        [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
       if (cell == nil) {
           cell = [[[UITableViewCell alloc] 
                     initWithStyle:UITableViewCellStyleDefault
                     reuseIdentifier:CellIdentifier] autorelease];
       }
    
       cell.textLabel.text = someTextYouDefine;
       cell.textLabel.textAlignment = UITextAlignmentCenter;
       cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
       // this is where the magic happens
       BOOL cellSelected = indexPath == self.firstSelection || 
                           indexPath == self.secondSelection; 
    
       cell.accessoryType = cellSelected ? UITableViewCellAccessoryCheckmark :
                                           UITableViewCellAccessoryNone;
    
       // the following two lines ensure that the checkmark does not cause
       // the label to be off-center
       cell.indentationLevel = cellSelected ? 1 : 0;
       cell.indentationWidth = 20.0f;
    
       return cell;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I add multiple objects to my NSArray? Each object will have the
I'm getting returned a list with objects that have multiple attributes like so: results
I have a program in which the user adds multiple objects to a scene.
I have multiple large objects which each have about 60 strings. I have to
I have multiple Controller objects that either execute some script and then redirect to
I have multiple business objects in my application (C#, Winforms, WinXP). When the user
I've got an observable collection that contains multiple DocumentEntry objects that each have a
I have a system written in java where I have multiple distinct objects each
I have a column chart with multiple series each containing multiple points. Currently the
In a networking project I have multiple objects that each have a message queue

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.