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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:44:29+00:00 2026-05-12T09:44:29+00:00

I see many Objective-C/Cocoa SDK apis where you can specify a target and an

  • 0

I see many Objective-C/Cocoa SDK apis where you can specify a target and an action that will get called back.

I want to do the same in two of my classes but when I store the passed in selector and later try to invoke it, I get the exception,

“unrecognized selector sent to
instance”

I pass off to ClassB the target and action like this:

[myClassB doSomething:self action:@selector(anAction:)];

ClassB is declared and implemented as this:

@interface ClassB
{
   id  target;
   SEL targetAction;
}

@implementation ClassB 

-(void)theWork {
if ( [target respondsToSelector:targetAction] ) 
{
    [target targetAction];
}
}

During the build process, I also get the following warning:

no ‘-targetAction’ method found

How can I invoke the target action that was supplied?

What I want to achieve is similar to this:

UIBarButtonItem *cancelButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
          target:self 
          action:@selector(cancelItem:)];
  • 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-12T09:44:29+00:00Added an answer on May 12, 2026 at 9:44 am
    [target targetAction];
    

    means to run the method called targetAction.

    you want

    [target performSelector:targetAction];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I see many user interface control libraries for .NET, but where can I get
I see many methods that specify an interface as return value. Is my thought
I'm new to Objective C. I see in many iPhone/iPad applications that after releasing
I see many, many sites that have URLs for individual pages such as http://www.mysite.com/articles/this-is-article-1
Sometime I see many application such as msn, windows media player etc that are
Sometime when looking through code, I see many methods specify an annotation: @SuppressWarnings(unchecked) What
I can understand that many years ago there would be this kind of limitation,
I see many sites that have address like this: http://www.myblog/2008/10/10/articl-title.aspx Question 1 If I
I searched over .... I see many advantages, but it seems that all the
I see many sites that suffer from this, and I've only been recently been

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.