• 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: Name of current function/selector
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Name of current function/selector


  • Subject: Re: Name of current function/selector
  • From: j o a r <email@hidden>
  • Date: Sat, 22 Oct 2005 19:40:43 +0200


On 22 okt 2005, at 19.13, Pontus Ilbring wrote:

There's a macro called __PRETTY_FUNCTION__ that returns the name of
the current function as a cstring.

And let me, for completeness sake, just add that you can access the selector of the currently executed ObjC method like this:


- (void) someMethod:(id) sender
{
NSLog(@"class: %@, method: %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd));
}


Doesn't work in plain C functions for obvious reasons.

Note how Apple's assertion macros for ObjC methods and C functions are different - for exactly this reason. The C variant uses __PRETTY_FUNCTION__, while the ObjC one uses _cmd.

j o a r


Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Name of current function/selector (From: Lawrence Sanbourne <email@hidden>)
 >Re: Name of current function/selector (From: Pontus Ilbring <email@hidden>)

  • Prev by Date: Re: Name of current function/selector
  • Next by Date: Re: How to change a Push Button's Color?
  • Previous by thread: Re: Name of current function/selector
  • Next by thread: Resizing bezier objects.
  • Index(es):
    • Date
    • Thread