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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:22:20+00:00 2026-06-08T00:22:20+00:00

I have really simple example, but I can’t understand how I could get information

  • 0

I have really simple example, but I can’t understand how I could get information about the method that call selector inside it. For example:

-(void)methodOne {
   [self performSelector:@selector(methodTwo:)];
}
-(void)methodTwo:(id)sender {
   //How to know which method performed selector???
}

I think this example is pretty simple, I just need to understand this, again, the question is, how could I know from methodTwo: which method perform selector, so from which method I called methodTwo:.

Thanks in advance!

  • 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-08T00:22:21+00:00Added an answer on June 8, 2026 at 12:22 am

    If you do want to know which method calls your methodTwo, you can look at call stack. Look at this …

    -(void)methodOne {
      [self performSelector:@selector(methodTwo:)];
    }
    
    -(void)methodTwo:(id)sender {
      NSLog( @"%@", [NSThread callStackSymbols][1]);
      NSLog( @"%@", [NSThread callStackSymbols][2]);
    }
    

    … and the log output (simplified) is …

    0x014ef671 -[NSObject performSelector:] + 62
    0x00002307 -[CMAppDelegate methodOne] + 55
    

    … callStackSymbols returns NSArray with call stack symbols, so, you can look at index 1 to get method which did you call your method. As you can see, there’s NSObject‘s performSelector and it’s because you called methodTwo via performSelector. If you change your methodOne in this way …

    -(void)methodOne {
      [self methodTwo:nil];
    }
    

    … the output is …

    0x000022fe -[CMAppDelegate methodOne] + 62
    0x000025d6 -[CMAppDelegate application:didFinishLaunchingWithOptions:] + 374
    

    … that’s it. Your question is answered, but I dunno why do you want this. You probably don’t want to know which method exactly did call your method, but which object initiated this call chain. An example is button – you can have one method to handle more buttons and there’s sender argument to distinguish between these buttons as @stavash pointed out.

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

Sidebar

Related Questions

I have a simple requirement, but can't get the SELECT statement right, so that
I have a really simple XML file that I'm trying to read, but I
I have what is probably a really simple, studid question but I can't find
Trying to do something really simple, but can't figure out the syntax. I have
hey guys having this really simple problem but cant seem to figure out have
Probably something really simple, but I'm having some real trouble with it. I have
It's probably something really simple, but I can't find it in the docs and
I need your help. I have made a really clean and simple example to
I've been trying to get this really simple example of using AJAX with JQuery
This seems like it should be really simple to do but I just can't

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.