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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:51:37+00:00 2026-06-01T06:51:37+00:00

I have the following code which takes a touch on one button and draws

  • 0

I have the following code which takes a touch on one button and draws a border around that button, then makes sure that all the other buttons have no border (8 buttons total). This is a method in a singleton class called AnswerButtons. This code works fine.

- (IBAction)button1WasTouched:(id)sender {

    NSLog(@"Hello from button 1");

    // retrieve, modify and update clueAnsState

    NSMutableArray *newCAS = [[GameData gameData].curData objectForKey:@"clueAnsState"];
   [newCAS replaceObjectAtIndex:0
                     withObject:@"2"];
    [[GameData gameData].curData setObject:newCAS
                                    forKey:@"clueAnsState"];

    // Highlight the pressed button & make sure other buttons are not highlighted

    for (NSInteger idx = 0; idx < 8; idx++) {
        NSString *temp = [newCAS objectAtIndex:idx];
        if ([temp isEqualToString:@"1"]) {
            UIButton *b = [[AnswerButtons answerButtons].buttons objectAtIndex:idx];
            [[b layer] setBorderWidth:0.0f];
        }
        if ([temp isEqualToString:@"2"]) {
            UIButton *b = [[AnswerButtons answerButtons].buttons objectAtIndex:idx];
            [[b layer] setBorderWidth:2.0f];
        }
    }

}

Now, I need to use this code for all 8 buttons, so I should write a method with one argument, the button number to modify (pos). In the singleton class .m I put which is virtually the same code:

    - (void)activateAnswerAtPos:(int)pos {

    // retrieve, modify and update clueAnsState

    NSMutableArray *newCAS = [[GameData gameData].curData objectForKey:@"clueAnsState"];
    [newCAS replaceObjectAtIndex:pos
                      withObject:@"2"];
    [[GameData gameData].curData setObject:newCAS
                                    forKey:@"clueAnsState"];

    NSLog(@"%@", newCAS);

    for (NSInteger idx = 0; idx < 8; idx++) {
        NSString *temp = [newCAS objectAtIndex:idx];
        if ([temp isEqualToString:@"1"]) {
            UIButton *b = [[AnswerButtons answerButtons].buttons objectAtIndex:idx];
            [[b layer] setBorderWidth:0.0f];
       }
       if ([temp isEqualToString:@"2"]) {
            UIButton *b = [[AnswerButtons answerButtons].buttons objectAtIndex:idx];
            [[b layer] setBorderWidth:2.0f];
        }
    }
}

So I changed the first code chunk to make it a call to the new method:

- (IBAction)button1WasTouched:(id)sender {

    NSLog(@"Hello from button 1");
    [sender activateAnswerAtPos:0];
}

Unfortunately, I’m doing something wrong as I get the following exception:

2012-03-30 19:41:40.199 P3[6751:f803] Hello from button 1
2012-03-30 19:41:40.201 P3[6751:f803] -[UIRoundedRectButton activateAnswerAtPos:]: unrecognized selector sent to instance 0x6e709f0

I’m not sure what’s going on here; several alternatives don’t work either and I think my troubleshooting is sending me in the wrong direction. What’s wrong with the way I am calling this method? Clearly I’m not even getting to run the method. TIA.

  • 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-01T06:51:38+00:00Added an answer on June 1, 2026 at 6:51 am

    You’re calling -activateAnswerAtPos: on sender, which is the button that was touched. You should instead call it on the instance of the class that defines the -activateAnswerAtPos: method. It’s not clear from your code what that is, but my guess is self:

    [self activateAnswerAtPos:0];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: <div><strong>Name: </strong><?php echo anchor('http://'.$link, $row->Name); ?></div> Which takes a
I have the following code, which basically takes values from a database and populates
I have the following code which takes a normal HTTP GET Request and returns
I have the following code which takes an improperly saved Image from the database
I have the following code which takes the data in a variable $main and
I have the following Code for a Button, which i want to built up
I have the following lines of code from my homework, which takes some numbers.
I have following code which works for radio buttons but need to be changed
I want to know is below code correct ? I have following code which
I'm trying to use opengl in C#. I have following code which fails with

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.