我正在尝试使用cURL从Cocoa应用程序向我的Yamaha接收器发送POST请求.我正在使用NSTask来实现这一点,并相信我的语法正确:
NSTask *task; task = [[NSTask alloc] init]; [task setLaunchPath: @"/usr/bin/"]; NSArray *arguments; arguments = [NSArray arrayWithObjects: @"-c", @"curl -v -X POST -H \"Content-type:text/xml\" --data 'xml=' http://172.19.24.23/YamahaRemoteControl/ctrl", nil]; [task setArguments: arguments]; [task launch]; On
我把它分配到我的应用程序中的一个按钮,它成功编译但是当我按下按钮时我会在日志中得到它.
2013-12-06 11:06:27.907 MyApp[18361:303] user clicked powerOnReceiver button 2013-12-06 11:06:27.909 MyApp[18361:303] Couldn't posix_spawn: error 13 2013-12-06 11:06:27.911 MyApp[18361:303] ( 0 CoreFoundation 0x00007fff897c641c __exceptionPreprocess + 172 1 libobjc.A.dylib 0x00007fff88e96e75 objc_exception_throw + 43 2 CoreFoundation 0x00007fff897c62cc +[NSException raise:format:] + 204 3 Foundation 0x00007fff87e71214 -[NSConcreteTask launchWithDictionary:] + 3167 4 MyApp 0x0000000100001c9a -[Receiver powerOnReceiver] + 218 5 MyApp 0x0000000100007053 -[AppDelegate powerOnReceiver:] + 67 6 AppKit 0x00007fff863733d0 -[NSApplication sendAction:to:from:] + 327 7 AppKit 0x00007fff8637324e -[NSControl sendAction:to:] + 86 8 AppKit 0x00007fff863bfd7d -[NSCell _sendActionFrom:] + 128 9 AppKit 0x00007fff863d9715 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2316 10 AppKit 0x00007fff863d8ae7 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 487 11 AppKit 0x00007fff863d81fd -[NSControl mouseDown:] + 706 12 AppKit 0x00007fff86359d08 -[NSWindow sendEvent:] + 11296 13 AppKit 0x00007fff862f8744 -[NSApplication sendEvent:] + 2021 14 AppKit 0x00007fff86148a29 -[NSApplication run] + 646 15 AppKit 0x00007fff86133803 NSApplicationMain + 940 16 MyApp 0x00000001000063e2 main + 34 17 libdyld.dylib 0x00007fff85ed05fd start + 1 )
我认为我的路径在这里是正确的,因此我不确定何时收到"无法posix_spawn:错误13"消息.任何想法将不胜感激.