Reputation: 16730
I'm at a point in a project where I need to call system commands. I originally started looking at NSTask (as that seems to be the most popular approach) but recently i just came across the system
command. It looks like a far easier setup that NSTask. I've seen some questions/answers that say NSTask is the better approach, but I don't see
Any help/links/thoughts/ideas? (and yes.. i did a google search)
Upvotes: 3
Views: 1439
Reputation: 9464
NSTask
:
NSString
s without having to do a buncha conversions.system(3)
-- I don't think system
even works on iOS.system(3)
:
/bin/sh
would.For a Cocoa app I always use NSTask
; I only use system
if I'm doing something that must be C-only or I know will have to run under non-Mac environments. As it is, system
is pretty brittle and the more robust solution is doing a fork
-exec
, because it allows you more control over streams and concurrent operation.
Upvotes: 10
Reputation: 16660
There are some differences. For some of them it is probably har to say in general, whether it is an advantage or not.
This are some differences out of my mind without rechecking the documentation. It is an overview.
Upvotes: 9