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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:07:00+00:00 2026-05-26T13:07:00+00:00

I have one table view within the app that I hope multiple parts of

  • 0

I have one table view within the app that I hope multiple parts of the app would be able to use to post updates to the table view with possible actions that the user can take. One of the ways that I thought of implementing this is via a large enum, with a switch statement with the table view. In this case, the table view would be performing an action based on the enum value for the table cell. This requires knowledge of the classes involved, and seems overly complicated.

There has to be a better way. Is it possible to use selectors with a target for the UITableViewCell accessory button?

I think that for regular buttons and navbar buttons I can do something like this:

[thisIconBtn addTarget:self action:@selector(changeIconState:) forControlEvents:UIControlEventTouchUpInside];

is there an equivalent way of assigning an action to the UITableView accessory? Or should I stick with the large enum?

thank you!

  • 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-26T13:07:00+00:00Added an answer on May 26, 2026 at 1:07 pm

    Unfortunately, the accessoryAction of a UITableViewCell is deprecated as of iOS 3.0.
    From the UITableViewCell Reference Docs:

    accessoryAction
    The selector defining the action message to invoke
    when users tap the accessory view. (Deprecated in iOS 3.0. Instead use
    the tableView:accessoryButtonTappedForRowWithIndexPath: for handling taps
    on cells.)

    However, if your accessory view inherits from UIControl (UIButton, etc), you may set a target and action through the addTarget:action:forControlEvents: method.

    Something like this (modify to fit your needs):

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:kCustomCellID];
        if (!cell) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCustomCellID] autorelease];
        }
    
        // Set the accessoryType to None because we are using a custom accessoryView
        cell.accessoryType = UITableViewCellAccessoryNone;
    
        // Assign a UIButton to the accessoryView cell property
        cell.accessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    
        // Set a target and selector for the accessoryView UIControlEventTouchUpInside
        [(UIButton *)cell.accessoryView addTarget:self action:@selector(someAction:) forControlEvents:UIControlEventTouchUpInside];
        return cell;
    }
    

    Or, the more traditional route (I’m not positive, but I believe your question states that this is what you are trying to avoid. You can ignore this block of code if that is true.):

    - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
        switch (indexPath.section) {
            case 0:
                switch (indexPath.row) {
                    case 0:
                        // <statements>
                        break;
                    case 1:
                        // <statements>
                        break;
                    default:
                        // <statements>
                        break;
                }
                break;
            case 1:
                switch (indexPath.row) {
                    case 0:
                        // <statements>
                        break;
                    case 1:
                        // <statements>
                        break;
                    default:
                        // <statements>
                        break;
                }
                break;
            default:
                break;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one table that saves comments for a varied set of content types.
I have one table that has sales records and another table that has additional
Lets say I have one table called REVIEWS This table has Reviews that customers
I love NHibernate's ability to have one table to store multiple types based on
Here is my situation: I have one table that contains a list of drugs
I have a nice clean UI within a table view which has a few
I have a table view which I'm using for some settings in my app.
I have an app that is controled through a UITabBar. In one of the
in my app, I have a table in one of the viewControllers. When one
I have a table view with 3 items, one of which I have behind

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.