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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:12:17+00:00 2026-05-28T01:12:17+00:00

I have the following code used to display some user information as well as

  • 0

I have the following code used to display some user information as well as a ‘invite’ button in a table cell. I am however not sure how I can access the cell’s information e.g. user again when I click on the invite button (in ‘inviteButtonPressed’ method) since I am unable to pass any parameters to the button click method. Can anyone advise me how I can access the cell’s information in the button click method?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString* PlaceholderCellIdentifier = @"SectionsTableIdentifier";
    GenericUser *user = [userSection objectAtIndex:row];

    UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:PlaceholderCellIdentifier];
    if (cell == nil)
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:PlaceholderCellIdentifier] autorelease];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.textLabel.font = [UIFont boldSystemFontOfSize:16];
        cell.textLabel.textColor = [UIColor darkGrayColor];

        UIButton *inviteButton = [self setupButtonWithTitle:@"Invite" andFrame:CGRectMake(224, (44-24)/2, 56, 24)];
        [inviteButton addTarget:self action:@selector(inviteButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
        inviteButton.tag = 1;
        [cell.contentView addSubview:inviteButton];

     }

    UIButton *thisInviteButton = (UIButton*)[cell.contentView viewWithTag:1];

    //This is where I will trigger the button press method
    [thisInviteButton addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
    UILabel *thisInvitedLabel = (UILabel*)[cell.contentView viewWithTag:2];

    cell.textLabel.text = user.name;
    cell.detailTextLabel.text = user.email;
    if (user.isSelected) 
    {
        thisInviteButton.hidden = YES;

    }
    else
    {
        thisInviteButton.hidden = NO;
    }

    return cell;
}



-(void)inviteButtonPressed:(id)sender
{
    //I want to access the cell information here. How can I do it? Basically I want to pass the user information belonging to the cell to this method

}
  • 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-28T01:12:18+00:00Added an answer on May 28, 2026 at 1:12 am

    You could subclass UIButton and add a property (let’s call it selectedIndexPath) to hold an NSIndexPath. Instead of an UIButton you place your subclass on the cell and set the index path after the line MyButton *thisInviteButton = (MyButton *)[cell.contentView viewWithTag:1];

    than you can do

    -(void)inviteButtonPressed:(id)sender
    {
        NSIndexPath *indexPath = [((MyButton *)b) selectedIndexPath];
        GenericUser *user = [userSection objectAtIndex:[indexPath row]];
    
    
    }
    

    or another approach, without the need of custom buttons:

    -(void)inviteButtonPressed:(id)sender 
    {
        UIButton *b = (UIButton *)sender;
        UITableViewCell* cell =  (UITableViewCell*)[[b superview] superview];
        NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
        GenericUser *user = [userSection objectAtIndex:[indexPath row]];
    
    }
    

    I am not sure, what approach I find less ugly.

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

Sidebar

Related Questions

i have used following code to repeat a process creation/close iteratively dim vProcessInfo as
I have used following code to create a simple PDF file. It executes fine
I have the following code - it is used to load a drop down
I have the following code in an Autofac Module that is used in my
I have used the following code in a number of applications to load .DLL
i have used the following code in .htaccess Options +FollowSymlinks RewriteEngine On RewriteBase /
I have used the code supplied in the following CodeProject article in the past
I have the following situation: Microsoft Report Viewer 2010 is used to display reports
I have the following code in an Asp.Net user control: Me.pnlAddComment.Visible = MyBase.Associate.IsAgent() Me.lblRating.Visible
I have the following as part of some code - you can see it

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.