• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to get the name of a method at runtime?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to get the name of a method at runtime?


  • Subject: How to get the name of a method at runtime?
  • From: Stuart Malin <email@hidden>
  • Date: Sat, 8 Mar 2008 22:44:00 -1000

I'd like to have a method determine the name of the method that invoked it -- as an NSString.

For example

- (void) method1 {
	[someObject method2];
}

- (void) method2 {
	// here, I'd like to be able to find the name of the caller
	// in this example, that would be "method1"
}

I have a suspicion that this is either trivial, and I'm just missing the obvious,
or its far from trivial and requires accessing the stack and some symbol table.


Any pointers (no pun intended) as to where I can find more information to understand the internal mechanisms would be appreciated.


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: How to get the name of a method at runtime?
      • From: "Sherm Pendley" <email@hidden>
  • Prev by Date: Re: How do I tell if the mouse button is down, independent of view, etc.?
  • Next by Date: Re: How to get the name of a method at runtime?
  • Previous by thread: Re: How do I tell if the mouse button is down, independent of view, etc.?
  • Next by thread: Re: How to get the name of a method at runtime?
  • Index(es):
    • Date
    • Thread