objective c - How should I go about creating a Cocoa application that outputs to the command-line? -


i'm attempting build cocoa application uses third-party cocoa api (it needs respond url-scheme). want application simple possible, , act "helper" application else.

it seems best way me have application launched command-line with arguments , write output, either directly cli or intermediary file such plist, before exiting.

how can best produce output (assuming dump command line), and/or there better way of going this?

general advice only, "best" subjective!

if producing multiple "blobs" (that's technical term ;-)) of output use c's standard i/o functions, if going output 1 blob can use write. basic approach is:

  1. produce output nsstring - anyway like
  2. use utf8string method of nsstring (or convert other character set encoding) produce c string
  3. output c string stdout fputs etc. or file descriptor 1 using write

if doing multiple times wrap above method takes format string/arguments needed etc.

you'll see cli applications produce output terminal in plist format, can useful applications helpers - calling application can read output via pipe , convert plist dictionary/array reading .plist file. more direct approach writing plist file , reading back.

but helpers don't need have cli or gui, can launch , communicate them various forms of ipc. if app sandboxed xpc helpers should considered.

hth


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -