1

Think i/o redirection, a lá 2>&1, but not as cryptic / annoying… Basically.. if you're debugging something.. Console messages back in the IDE aren't very useful. So I thought.. OK, I'll just redirect NSLog, stdout- style. But how? I'm a nincompoop in the C department, but I'm sure you eager beavers will jump in with some simple #define - or other pre-processor idiosyncrasy - perfect for just this type of occasion. So, in pictures…

the attempt

No errors. Logs to console AOK, as seen below.

Normal LOG, aok

But as I had feared.. No bound output, except for %@.

No dice in my window

How, may I simply, either synthesize an IBOutlet instance of NSLog, or otherwise capture it for further abuse and misuse?

∀Ⓛ∃✖

Community
  • 1
  • 1
Alex Gray
  • 16,007
  • 9
  • 96
  • 118

1 Answers1

5

NSLog simply writes to stderr, so you can use the freopen function to log the output to a file as described here:

Logging to a file on the iPhone

Once you have the data in a file, you could read from that file and put the results in a view.

If you want more of a real-time view than polling a file could provide, you might be able to redirect stderr to a pipe using the NSPipe class. I've never tried it, but this link might help:

http://www.cocoabuilder.com/archive/cocoa/110139-redirect-stderr-to-nstextview.html

Community
  • 1
  • 1
Eric Petroelje
  • 59,820
  • 9
  • 127
  • 177