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 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

Ask A Question

Stats

  • Questions 273k
  • Answers 273k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Why don't you just make these 3 classes static? I'm… May 13, 2026 at 2:11 pm
  • Editorial Team
    Editorial Team added an answer Seems like this ability is not provided by the HTTP… May 13, 2026 at 2:11 pm
  • Editorial Team
    Editorial Team added an answer It'll use the default GTK+ font settings, as Eclipse is… May 13, 2026 at 2:11 pm

Related Questions

in linux, let say i want to start tomcat, and want to direct all
Trying to debug an issue with a server and my only log file is
I have the following code: using System; using System.Diagnostics; using System.IO; using PdfSharp.Pdf.Printing; namespace
The following is an extract from my code: public class AllIntegerIDs { public AllIntegerIDs()

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.