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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:58:21+00:00 2026-05-30T00:58:21+00:00

Is it possible to send a selector to another class and have it perform

  • 0

Is it possible to send a selector to another class and have it perform on that other class?

This seems to crash with the error *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[webManager _selector]: unrecognized selector sent to instance. If this is not possible, what would you recommend as an alternative?

The methods are placed in the order that they are performed.

//in HomeViewController
-(void)viewDidLoad
{
    WebManager *webManager = [[WebManager alloc] init];
    URLCreator *urlCreator = [[URLCreator alloc] initWithParam:@"default"];
    [webManager load:[urlCreator createURL] withSelector:@selector(testSelector)];
}
//in WebManager, which is also the delegate for the URL it loads when the load method is called...
-(void)load:(NSString*)url withSelector:(SEL)selector
{
    _selector = selector;    
    [self load:url];
}

-(void)load:(NSString*)url{
    NSURLRequest * request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:url]];
    NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
    [connection start];
}

//now the delegate response, ALSO in WebManager
-(void)connectionDidFinishLoading:(NSURLConnection *)connection{
    NSLog(@"Connection did finish loading. Parsing the JSON");

    [self getJSONDict:rawData]; //parses the data to a dictionary

    //perform the selector that is requested if there is one included
    if (_selector)
    {
        NSLog(@"Performing selector: %@", NSStringFromSelector(_selector));
        //the selector is called testSelector
        [self performSelector:@selector(_selector)];    
    }
}

- (void)testSelector //also in the WebManager class
{
    NSLog(@"Selector worked!");
}
  • 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-30T00:58:22+00:00Added an answer on May 30, 2026 at 12:58 am

    This is your problem:

    [self performSelector:@selector(_selector)];
    

    A SEL is a type representing the name of a method. @selector is a compiler directive which converts the literal text inside the brackets into a SEL.

    But _selector, your ivar, already contains a SEL. You’re converting the text “_selector” into a SEL, and then trying to use that. Since no method with the selector “_selector” exists in the target class, you get an exception.

    Change the line to:

    [self performSelector:_selector];
    

    and everything should be dandy. This uses the SEL which you already have stored in the variable _selector.

    Also, generally speaking, please post your real code initially.

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

Sidebar

Related Questions

Is it possible to send the Validate error message to other function? As an
It seems that UISegmentedControl objects only send out UIControlEventValueChanged events. Is it possible to
Is it possible to send pre-compressed files that are contained within an EARfile? More
In my current .NET and FBML-based facebook app, I have some code that looks
Is it possible send a parameter when installing an app from appstore? My idea
Is it somehow possible to send a function to another function for it to
Is it possible to send a status code other than 200 via a python
Is it possible to send additional custom headers (for example with a wsgi app)
Is it possible to send HTML emails from WP7? I might have overlooked it
Is it possible to send keystrokes to a cocoa app? I don't want to

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.