• 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
Re: How to get the name of a method at runtime?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get the name of a method at runtime?


  • Subject: Re: How to get the name of a method at runtime?
  • From: Mike Abdullah <email@hidden>
  • Date: Sun, 9 Mar 2008 21:15:21 +0000


On 9 Mar 2008, at 19:18, Stuart Malin wrote:

Thanks Jon and Shem. I spaced out the existence of _cmd and was unaware of __func__

As I best understand their distinction:

	__func__ is generated at compile time (a C-string)

	_cmd is part of the Obj-C runtime (a SEL)

Since I am writing a new method, I can accomplish my goal by passing either _cmd or __func__.

BUT, just out of intellectual curiosity (and possible future need), what if I have existing callers and can't modify their code to pass either of these -- can I still get the identity of the invoking method in my method?
Of course, that would be objc_msgSend. So... the one before that?
Which leads back to the stack.... and method signatures and frame lengths, and ... I think I'm over my head.


Is there something else simple that I've missed? Or there is documentation somewhere on these mechanics that I should be reading?

Nothing you've missed, there really is no simple way to find this information out without delving into the stack. However, trying to do this is a pretty bad idea on the whole anyway; code that depends on specific other methods calling it like that is probably going to be rather fragile and suggests a weakness in the design.


Mike.
_______________________________________________

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


References: 
 >How to get the name of a method at runtime? (From: Stuart Malin <email@hidden>)
 >Re: How to get the name of a method at runtime? (From: "Sherm Pendley" <email@hidden>)
 >Re: How to get the name of a method at runtime? (From: Stuart Malin <email@hidden>)

  • Prev by Date: Re: how to get a particular icon from .icns file
  • Next by Date: Re: How to get the name of a method at runtime?
  • Previous by thread: Re: How to get the name of a method at runtime?
  • Next by thread: Re: How to get the name of a method at runtime?
  • Index(es):
    • Date
    • Thread