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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:40:12+00:00 2026-06-06T03:40:12+00:00

First off tags wont work. I say this because i create 4 buttons all

  • 0

First off tags wont work. I say this because i create 4 buttons all with the same tag for a specific cell i.e indexPath.row = tag.

Inside My TableViewCellForRowAtIndexpath

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"courseCell";

//Step 1: Check to se if we can reuse a cell from a row that has just rolled off the screen
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

//step 2: If there are no cell to reuse, create a new one
if (cell == nil){
    cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    cell.selectionStyle = UITableViewCellSelectionStyleGray;
}
...


    //-------------Creation of Custom Buttons-------------// 

    //-----img = "radioOn.png"-----//
    //----img2 = "radioOff.png"----//

    //----RadioButtonA----//
    ...

    radioButtonA = [UIButton buttonWithType:UIButtonTypeCustom];

    [radioButtonA addTarget:self action:@selector(radioButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
    radioButtonA.tag=indexPath.row;

    //----End RadioButtonA----//

    //----RadioButtonB----//

    radioButtonB = [UIButton buttonWithType:UIButtonTypeCustom];
    [radioButtonB addTarget:self action:@selector(radioButtonClicked:)forControlEvents:UIControlEventTouchUpInside];
   radioButtonB.tag =indexPath.row;
...

    //----End RadioButtonB----//

    //----RadioButtonC----//

    radioButtonC = [UIButton buttonWithType:UIButtonTypeCustom];
    [radioButtonC addTarget:self action:@selector(radioButtonClicked:)forControlEvents:UIControlEventTouchUpInside];
    radioButtonC.tag = indexPath.row;
...

    //----End RadioButtonC----//

    //----RadioButtonNA----//

    radioButtonNA = [UIButton buttonWithType:UIButtonTypeCustom];
    radioButtonNA.tag = indexPath.row;
    [radioButtonNA addTarget:self action:@selector(radioButtonClicked:)forControlEvents:UIControlEventTouchUpInside];

    ...

    //----End RadioButtonC----//

    //---------End of Radio Button Creations---------//

    //---------UIStepper & StepperLabel Creation-----//




    [cell.contentView addSubview:radioButtonA];
    [cell.contentView addSubview:radioButtonB];
    [cell.contentView addSubview:radioButtonC];
    [cell.contentView addSubview:radioButtonNA];

//Step4: Return the cell
return cell;
}

#pragma mark - Buttons

- (void)radioButtonClicked:(UIButton *)sender
 {

UIButton *myButton = sender;


// This Method and all the ones similar to this method is created to handle the UITouchUpInsideEvent that the user sends when pressing the radioButtons A-NA.

[radioButtons addObject:sender];

// Create an instance(object) of class NSIndexPath called indexPath and set its value the indexPath of the cell the user is currently in.
UITableViewCell *cell = (UITableViewCell *)[[sender superview] superview];
NSIndexPath *indexPath = [myTableView indexPathForCell:cell];


// Initialize two unique variables in order to check if the buttons being clicked are being referenced in the correct index. 
int row = indexPath.row;
NSLog(@"Button is in row %d", row);

...

}

-(IBAction)button:(UIButton*)sender{
  ...
@try {
    for (i=0; i<8; i++) {

        if ([credits count ] ==0) {
            break; 
        }

HERE is where i am trying to access the radiobuttons i created in my cell. What i would like to do is this

if([credits objectAtIndex:i]) == radioButtonA{

do stuff. The reason im not saying == [radioButtonA tag] is because i have three other buttons all with the same tag. If your read the code u see why the tags are set this way.
}

What I am asking for is 1 help, and 2 is there another way to check if two Buttons i.e objects are equal without having to rely on their tags.

Do not worry about the Try catch finally i was using it to catch the exception being thrown.

        if ([[[[credits objectAtIndex:i]titleLabel]text] isEqualToString:@"A"])  {
            NSLog(@"radioA is in array");
            creditHours+=[[valueArray objectAtIndex:i]doubleValue];
            gradeEarned+=(GradeA.doubleValue *[[valueArray objectAtIndex:i]doubleValue]);
            NSLog(@"%f",gradeEarned);
            continue;
        }

        if ([[[[credits objectAtIndex:i]titleLabel]text] isEqualToString:@"B"]) {
            NSLog(@"radioB is in array");
            creditHours+=[[valueArray objectAtIndex:i]doubleValue];
            gradeEarned+=(GradeB.doubleValue *[[valueArray objectAtIndex:i]doubleValue]);
            continue;
        }

        if ([[[[credits objectAtIndex:i]titleLabel]text] isEqualToString:@"C"]){
            NSLog(@"radioC is in array");
            creditHours+=[[valueArray objectAtIndex:i]doubleValue];
            gradeEarned+=(GradeC.doubleValue *[[valueArray objectAtIndex:i]doubleValue]);
            continue;
        }

        if([credits objectAtIndex:i]== radioButtonNA){
            NSLog(@"boboboobbobob");
            continue;
        }
    }
}
@catch (NSException *exception) {
    NSLog(@"NSException Caught");
    NSLog(@"Name: %@",exception.name);
    NSLog(@"Reason: %@", exception.reason);
}
@finally {
    NSLog(@"in finally block");
}

//        if ([credits objectAtIndex: i] == defaulter) {
//                        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Failed to select all grades" message:[NSString stringWithFormat:@"Your grade selections have been reset"] delegate:self cancelButtonTitle:@"great"otherButtonTitles:nil];
//                        [alert show];
//                        [alert release];
//            [self refreshArray];
//        }


NSLog(@"%f",gradeEarned);

if (gradeEarned == 0) {
    textLabel.text= [NSString stringWithFormat:@"%f",gradeEarned];
}else {
    NSLog( @"boob");
    sum= (gradeEarned)/(creditHours);
    NSLog(@"%f",sum);
    textLabel.text= [NSString stringWithFormat:@"%f",sum];
    //[self refreshArray];
}

}

For more information Here is the log…
NSLog(@”%@”,[credits objectAtIndex:i]);
NSLog(@”%@”,radioButtonA);

      THE First output is the log of the [credits object atIndex:i]  

UIButton: 0x6c91430; frame = (86 110; 32 30); opaque = NO; layer = CALayer: 0x6c914f0

2012-06-20 20:24:01.568 TableView[12557:f803] UIButton: 0x6ea8ad0; frame = (86 110; 32 30); opaque = NO; tag = 6; layer = CALayer: 0x6e746e0

As you can see The UIBUttons are DIFFERENT thus == operator does not work

  • 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-06T03:40:13+00:00Added an answer on June 6, 2026 at 3:40 am

    I’m not sure, in the method,
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
    you should add the buttons only when the cell is nil.just like this

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *CellIdentifier = @"courseCell";
    
        //Step 1: Check to se if we can reuse a cell from a row that has just rolled off the screen
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
        //step 2: If there are no cell to reuse, create a new one
        if (cell == nil)
        {
             cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
             cell.selectionStyle = UITableViewCellSelectionStyleGray;
             //-------------Creation of Custom Buttons-------------// 
    
             //-----img = "radioOn.png"-----//
             //----img2 = "radioOff.png"----//
    
             //----RadioButtonA----//
              ...
    
             radioButtonA = [UIButton buttonWithType:UIButtonTypeCustom];
    
             [radioButtonA addTarget:self action:@selector(radioButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
             radioButtonA.tag=indexPath.row;
    
             //----End RadioButtonA----//
    
             //----RadioButtonB----//
    
             radioButtonB = [UIButton buttonWithType:UIButtonTypeCustom];
             [radioButtonB addTarget:self action:@selector(radioButtonClicked:)forControlEvents:UIControlEventTouchUpInside];
             radioButtonB.tag =indexPath.row;
             ...
    
    //----End RadioButtonB----//
    
    //----RadioButtonC----//
    
             radioButtonC = [UIButton buttonWithType:UIButtonTypeCustom];
             [radioButtonC addTarget:self action:@selector(radioButtonClicked:)forControlEvents:UIControlEventTouchUpInside];
             radioButtonC.tag = indexPath.row;
             ...
    
    //----End RadioButtonC----//
    
    //----RadioButtonNA----//
    
               radioButtonNA = [UIButton buttonWithType:UIButtonTypeCustom];
               radioButtonNA.tag = indexPath.row;
             [radioButtonNA addTarget:self action:@selector(radioButtonClicked:)forControlEvents:UIControlEventTouchUpInside];
    
    ...
    
    //----End RadioButtonC----//
    
    //---------End of Radio Button Creations---------//
    
    //---------UIStepper & StepperLabel Creation-----//
    
    
    
    
           [cell.contentView addSubview:radioButtonA];
           [cell.contentView addSubview:radioButtonB];
           [cell.contentView addSubview:radioButtonC];
           [cell.contentView addSubview:radioButtonNA];
     }
         ...
    
        //Step4: Return the cell
        return cell;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First off, if it's not clear from the tag, I'm doing this in PHP
First off let me say this is my first ASP.NET project I have done.
First off, I am not a DBA, but I do work in an environment
First off the html row looks like this: <tr class=evenColor> blahblah TheTextIneed blahblah and
First off, I'm aware this is a bad practice and I have answered many
First off, thank you to everyone on this site...it's been INCREDIBLY helpful in getting
First off, let me start by saying, I know this exact question has been
First off, the barest bones of the project I wish to create is a
First off - apologies if this or a similar question has been asked before.
First off, I am wondering if this is possible. I read slight grumblings around

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.