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

  • SEARCH
  • Home
  • 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 468481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:41:10+00:00 2026-05-12T23:41:10+00:00

I print out something to the console using NSLog() . Is there a way

  • 0

I print out something to the console using NSLog(). Is there a way to pass all the current method’s arguments to NSLog(), or any other function or method, without looking at each of them explicitly?

For example, I already have a macro that prints useful information to the console when I just put LOGME in my code. The macro will create a call to a singleton class’s logging-method and pass several useful things like _cmd and other stuff.

I would also like to catch all the arguments of that method and pass them on for printing them out automatically. Is that possible?

  • 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-05-12T23:41:10+00:00Added an answer on May 12, 2026 at 11:41 pm

    Use gdb. You can set a break point that logs the arguments to the method and continues.

    If you insist on doing it the hard way… It’s certainly not simple, but you could use the stack structure on a given architecture/ABI and make use of the Objective-C runtime to figure out how many arguments and of what size to look for. From here on out, I’m in unchartered territory; I’ve never done this nor would I ever bother. So YMMV…

    Within your method, you can get the Method struct, then the number of arguments, then each argument type and the its size. You could then walk the stack from the address of the self parameter (i.e. &self), assuming you knew what you were doing…

    Method method = class_getInstanceMethod([self class], _cmd);
    unsigned nargs = method_getNumberOfArguments(method);
    void *start = &self;
    for(unsigned i = 0; i<nargs; i++) {
      char *argtype = method_copyArgumentType(method, i);
      //find arg size from argtype
      // walk stack given arg zie
      free(argtype);
    }
    

    Along the way you’d have to convert from the argtype string (using the Objective-C type encodings) to the size of each argument on the stack.

    Of course then you’d have to derive the format string for each type, and call NSLogv with an appropriate variable argument array containing the arguments, copied from their location on the stack. Probably a lot more work than its worth. Use the debugger.

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

Sidebar

Related Questions

Is there a way to print out the diffs like they show when you
I'm using SQL Server 2000 to print out some values from a table using
I need to print out data into a pre-printed A6 form (1/4 the size
Can i print out a url /admin/manage/products/add of a certain view in a template?
I'm trying to print out the date in a certain format: NSDate *today =
Attempting to print out a list of values from 2 different variables that are
I like to print out software requirements so I can easily mark them up,
I seem to remember being able to print out (or locate) the specific switches
Can a Java Applet able to print out text/html easily to standard printer driver(s)
In Ruby, trying to print out the individual elements of a String is giving

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.