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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:27:46+00:00 2026-06-07T02:27:46+00:00

I have an interesting scenario. I have a custom TableViewCell class which contains a

  • 0

I have an interesting scenario.
I have a custom TableViewCell class which contains a button.
What I would like to do is catch the touch event of the button inside the custom cell class and throw a new event for the container control(ler) to handle.

Reason for this is that I have a cell with a button marked as “Archive”. Now instead of handling the cell code in the custom TableViewController I want to intercept the button call first as I need to hide the archive button and tell the container control (or the TableViewController) to handle an “archive event has occurred on cell X”.
I don’t want the controller to know what goes on inside a cell. That way I have some reusable and cleaner code.

So the controller should be able to receive the event and form the event determine which cell is involved in order to know which record it needs to remove.
I can achieve this with the NSNotificationCenter class and have observers take care of it for me but it would be great (I think, don’t know if you’ll agree) if I can have it raised as an event instead.

Can this be done with iOS development?

I hope my question makes sense.

Thanks

EDIT: It seems that I’ve been misunderstood. So let me make it clear (unless this isn’t possible at all), I do not want the TableViewController to know about the button inside the cell. The Controller needs to receive an event generated by the cell because it caught the original button touch event and from there inside the cell a new event needs to be generated which the controller can catch. Similar to what you can do in the .NET world.
However if this cannot be done please let me know. The reason is for cleaner and reusable code.

  • 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-06-07T02:27:48+00:00Added an answer on June 7, 2026 at 2:27 am

    Unless someone can show me a better way, I’m going with this approach.

    Say you have a TableViewController:

    @interface CustomViewController : UITableViewController<ArchiveItemDelegate> ...
    

    and you have a Custom TableViewCell:

    @interface CustomCell : UITableViewCell ...
    

    with the delegate property using the delegate protocol below.

    Now I’ve created a protocol:

    @protocol ArchiveItemDelegate <NSObject>
    
    -(void)archiveActionPerformed:(CustomCellData *)cellData onCell:(CustomCell *)cell;
    
    @end
    

    Inside my CustomCell implementation I attach an event listener on the archive button:

    - (void)archiveButtonPressed:(UIButton *) sender forEvent:(UIEvent *)event {
        [self.delegate archiveActionPerformed:currentCellData onCell:self];
    }
    

    Now in my TableViewController I let it “inherit” from the ArchiveItemDelegate protocol and implement it.

    -(void)archiveActionPerformed:(CustomCellData *)cellData onCell:(CustomCell *)cell {
        // do whatever ...
    }
    

    Now in my “tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath” method I just attach the TableViewController to the cell.

    cell.delegate = self;
    

    Now my TableViewController doesn’t know of the internals of the Cell and the cell notifies of an “archive event” when the Archive button is tapped. This might “evolve” a bit but for now I think will do. If someone has a better solution please let me know. You can see I come from the .NET space 😉

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

Sidebar

Related Questions

I have an interesting scenario. I have a task model which has a task
I just came across an interesting scenario. I have a class in C#: public
I'm using SQL Server 2008. I have an interesting scenario where a stored procedure
I have the following interesting scenario: I've install ruby 1.9.2 via RVM and it
I have an interesting question on initialization. I have the following code: public class
I have an interesting situation that EMF forced me into: abstract class AbstractDog{ ...
I have an interesting dilemma to which, I hope, someone may have an answer.
Got an interesting scenario I'd like to run past you guys re: DB architecture.
I have a custom project type based on the C# Class Library project type
Here is the situation: I have created a custom view class with UITextView as

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.