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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:43:42+00:00 2026-06-15T09:43:42+00:00

I have a special NSLog method swizzle that prints the current method as part

  • 0

I have a special NSLog method swizzle that prints the current method as part of the log statement.

For Objective-C methods, I have a macro that uses: NSStringFromSelector(_cmd)

For non Objective-C methods, I have a second macro that uses __PRETTY_FUNCTION__ because _cmd is not defined.

I am now trying to use the same macro for both, so I am trying to test if it is defined and thought I could do so like this:

NSString *command = (&_cmd != nil ? NSStringFromSelector(_cmd) : [NSString stringWithCString:__PRETTY_FUNCTION__ encoding:NSUTF8StringEncoding])

but I am still getting some Use of undeclared identifier '_cmd' errors when the macro is used in non Objective-C methods. How can I do a runtime test do determine if _cmd is defined or not?

  • 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-15T09:43:44+00:00Added an answer on June 15, 2026 at 9:43 am

    You cannot test at runtime whether _cmd is defined.

    The __PRETTY_FUNCTION__ macro is defined in Objective-C methods. Just use __PRETTY_FUNCTION__ everywhere and don’t try to use _cmd.

    Example:

    - (IBAction)mapWasTapped:(UITapGestureRecognizer *)sender {
        NSLog(@"%s", __PRETTY_FUNCTION__);
    }
    

    Here’s the output:

    2012-12-01 11:45:30.036 TestApp[92581:c07] -[MainViewController mapWasTapped:]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some special parameters to all my wcf service methods that are handled
Do you have any unique or special uses of NSLog you use for debugging?
I have a class that defines the __complex__ special method. My class is not
Ok, I understand that using strings that have special characters is an encoding issue.
I have seen a few OSX apps that have a Special Characters menu item
I seem to remember that Regular Expressions in DotNet have a special mechanism that
Does the iPhone browser have special events that I can hook into with Javascript?
Some of my .csproj project files have special target AssembleJS that merges all .js
Is the Java String data that I will fetch complete if I have special
I have a set of methods that all synchronize to the class object (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.