Output an NSString to STDOUT in Objective-C
Admittedly, this is something you wouldn't often want to do unless writing an command line application in Objective-C/Cocoa, but writing to STDOUT instead of using
NSLog(@"%@", object);
Means that the response can be used by piping to pbcopy for example. So do this instead:
[aString writeToFile:@"/dev/stdout" atomically:NO encoding:NSUTF8StringEncoding error:nil];
And then your string will output to stdout instead of just posting a console log.
Written by Max Woolf
Related protips
1 Response
it works but it seems weird! nice to know how NSLog output things
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Cli
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#