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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:11:24+00:00 2026-06-04T08:11:24+00:00

I have the following program structure: -(UITableViewCell *)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { … … if(cell

  • 0

I have the following program structure:

-(UITableViewCell *)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {

       ...

       ...


       if(cell == nil)
        {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SimpleTableIdentifier] autorelease];

            ...

            ...


            if(condition)
                {   
                    do something;
                }

            else
                {

                    if(condition)
                         {  
                            unFollowButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
                            unFollowButton.frame = CGRectMake(180, 10, 120, 30);

                            unFollowButton.titleLabel.font = [UIFont systemFontOfSize:12];
                            unFollowButton.tag = indexPath.row;
                            unFollowButton.titleLabel.textColor = [UIColor blackColor];
                            [unFollowButton addTarget:self action:@selector(buttonClicked2:) forControlEvents:UIControlEventTouchUpInside];
                            NSLog(@"fCheckRowCheck Value in if Condition %@",fCheckRowCheck);
                            [unFollowButton setTitle:@"UnFollow" forState:UIControlStateNormal];
                            [cell.contentView addSubview:unFollowButton];
                            buttonValue = 0;
                            NSLog(@"buttonValue %d", buttonValue);
                        }

                    else 
                        {

                            followButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
                            followButton.frame = CGRectMake(180, 10, 120, 30);
                            followButton.titleLabel.font = [UIFont systemFontOfSize:12];
                            followButton.tag = indexPath.row;
                            followButton.titleLabel.textColor = [UIColor blackColor];
                            [followButton setTitle:@"Follow" forState:UIControlStateNormal];
                            [followButton addTarget:self action:@selector(buttonClicked1:) forControlEvents:UIControlEventTouchUpInside];
                            [cell.contentView addSubview:followButton];
                            buttonValue = 1;
                            NSLog(@"buttonValue %d", buttonValue);
                        }   
                }
        }


    NSUInteger row = [indexPath row];
    cell.textLabel.text = [self.infos objectAtIndex:row];
    return cell;

}




- (IBAction)buttonClicked2:(UIButton *)sender
    {
       NSLog(@"BUTTON_CLICKED");

       NSIndexPath *indexPath = [folksFolksTable indexPathForCell:(UITableViewCell*)  [[sender superview]superview]];
       NSLog(@"[sender tag] is %d", [sender tag]);

       ....

       ....

       ....

       //Set up URLConnection tp send information on button click
       NSMutableString *postString = [NSMutableString stringWithString:kUnFollowURL];
    [postString appendString: [NSString stringWithFormat:@"?%@=%@", kId, [user objectForKey:@"id"] ]];
    [postString appendString: [NSString stringWithFormat:@"&%@=%@", kfId, [fId objectForKey:@"fID"] ]];

    [postString setString: [postString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    NSLog(@"post string = %@", postString);

    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:postString]];

    [request setHTTPMethod:@"POST"];

    followConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];
    NSLog(@"postconnection: %@", followConnection);

    //Get Response from server

    NSData *dataURL =  [NSData dataWithContentsOfURL: [ NSURL URLWithString: postString ]];    
    NSString *serverOutput = [[NSString alloc] initWithData:dataURL encoding: NSASCIIStringEncoding];

    NSLog(@"serverOutput = %@", serverOutput);

    //Change the button lable from unfollow to follow

    [sender setTitle:@"Follow" forState:UIControlStateNormal]; 




     if([sender tag]==indexPath.row)
        {
            textField = (UITextField*)[cell viewWithTag:[sender tag]];
            NSLog(@"txtF is %@",textField);        
            textField.hidden=NO;
        }


}

- (IBAction)buttonClicked1:(UIButton *)sender
      {

          similar to buttonClicked 2

      }

What I need is that the button should perform the corresponding action as well after the label has changed during runtime.

For example, I am following someone [ button label unfollow], if i click on the button [ button label becomes follow at that instant ( which is happening perfectly OK ). Now when i click the same button again with “follow” label, it is throwing exception.

How to go about it. Please help me figure it out ?

  • 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-04T08:11:25+00:00Added an answer on June 4, 2026 at 8:11 am

    EDIT: solved it. I had added previously the following line of code after

    [sender setTitle:@”Follow” forState:UIControlStateNormal];

     [sender addTarget:self action:@selector(buttonClicked2:) forControlEvents:UIControlEventTouchUpInside];
    
    cause of exception was i added colon (:) twice after @selector(buttonClicked2) whereas i need only one colon.
    

    I hope this question serves as reference to other users as well.

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

Sidebar

Related Questions

I have the following structure in the program: Using transaction As New TransactionScope() 'Make
I have the following XML structure: <?xml version=1.0 encoding=utf-8 standalone=yes?> <Root xmlns:xsi=My Program> <NotRoot
I have the following structure for my project and developer program: developer table id
I have the following program. It is object oriented, having a structure 'array' (I
I have following Structure in my Program. #define WIFI_DEVICE_NAME 100 #define WIFI_SERIAL_NO 13 #define
I have a simple multi-threaded program, with the following structure. public void someFunction() {
I have following simple program: import std.stdio; int main(string[] argv) { writeln(Hello, world!); return
I have the following program to open lot's of sockets, and hold them open
I have the following program to browse all virtual directories and their sub directories
Hi I have the following program. When I compile on the terminal gcc main.c

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.