Reputation: 16463
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…
No errors. Logs to console AOK, as seen below.
But as I had feared.. No bound output, except for %@
.
How, may I simply, either synthesize an IBOutlet instance of NSLog, or otherwise capture it for further abuse and misuse?
∀Ⓛ∃✖
Upvotes: 1
Views: 1161
Reputation: 60498
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
Upvotes: 5