NSTask没有按预期/希望的那样工作

时间:2014-12-14 13:38:33

标签: objective-c macos terminal nstask

get_iplayer允许用户从BBC iPlayer服务下载文件。它真棒,它们都是。

我正在尝试使用NSTask从Xcode中运行get_iplayer命令:

NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/users/myuser/documents/get_iplayer_install/get_iplayer"];
NSArray *args = @[@"--type=radio",@"--pid",  @"--modes=flashaacstd,rtspaaclow",  @"b006tnvx"];
[task setArguments:args];
[task launch];
[task waitUntilExit];

这是为了完成与从终端运行时相同的工作:

get_iplayer --type=radio --pid b006tnvx

然而,它产生了这个输出:

get_iplayer v2.90, Copyright (C) 2008-2010 Phil Lewis
This program comes with ABSOLUTELY NO WARRANTY; for details use --warranty.
This is free software, and you are welcome to redistribute it under certain
conditions; use --conditions for details.

WARNING: rdf URL contained no data
WARNING: PID URL contained no RDF data. Trying to record PID directly.
INFO: Trying pid: --modes=flashaaclow using type: radio
INFO: Trying to stream pid using type radio
INFO: pid not found in radio cache
Matches:

INFO: 1 Matching Programmes

ERROR: Failed to get version pid metadata from iplayer site

WARNING: rdf URL contained no data
WARNING: PID URL contained no RDF data. Trying to record PID directly.
INFO: Trying pid: flashaacstd using type: radio
INFO: Trying to stream pid using type radio
INFO: pid not found in radio cache
Matches:

INFO: 1 Matching Programmes

ERROR: Failed to get version pid metadata from iplayer site

Program ended with exit code: 0

虽然它应该产生之类的东西这个:

enter image description here

我认为这不是一个get_iplayer问题,而是我对NSTask缺乏了解,可能还有unix的工作方式。

你能指出我正确的方向吗?

干杯, 安迪

1 个答案:

答案 0 :(得分:1)

你的论点顺序错误。您在值中的--pid参数之间获得了--modes参数和值。

输出结果说,它无法找到名称为--modes = flashaaclow

的pid