l'L*_*L'l 8 macos objective-c nstask swift
在最近的苹果文档都NSTask和Process有一些过时的方法和属性,虽然没有什么标有API Availability Macro.
实例属性
@property(copy) NSString *launchPath;
@property(copy) NSString *currentDirectoryPath;
var launchPath: String? { get set }
var currentDirectoryPath: String { get set }
Run Code Online (Sandbox Code Playgroud)
实例方法
- (void)launch;
func launch()
Run Code Online (Sandbox Code Playgroud)
类型方法
+ (NSTask *)launchedTaskWithLaunchPath:(NSString *)path
arguments:(NSArray<NSString *> *)arguments;
class func launchedProcess(launchPath path: String,
arguments: [String]) -> Process
Run Code Online (Sandbox Code Playgroud)
似乎没有替代品可用,所以给出了什么?
vad*_*ian 12
似乎没有替代品
有,API现在与URL相关
实例属性
@property(copy) NSURL *executableURL;
@property(copy) NSURL *currentDirectoryURL;
var executableURL: URL? { get set }
var currentDirectoryURL: URL? { get set }
Run Code Online (Sandbox Code Playgroud)
实例方法
- (BOOL)launchAndReturnError:(out NSError * _Nullable *)error;
func run() throws
Run Code Online (Sandbox Code Playgroud)
类型方法
+ (NSTask *)launchedTaskWithExecutableURL:(NSURL *)url
arguments:(NSArray<NSString *> *)arguments
error:(out NSError * _Nullable *)error
terminationHandler:(void (^)(NSTask *))terminationHandler;
class func run(_ url: URL,
arguments: [String],
terminationHandler: ((Process) -> Void)? = nil) throws -> Process
Run Code Online (Sandbox Code Playgroud)