Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSTask / Process deprecated methods and properties

In the most recent Apple documentation both NSTask and Process have several deprecated methods and properties, although there's nothing marked with an API Availability Macro.

Instance Properties

@property(copy) NSString *launchPath;
@property(copy) NSString *currentDirectoryPath;

var launchPath: String? { get set }
var currentDirectoryPath: String { get set }

Instance Methods

- (void)launch;

func launch()

Type Methods

+ (NSTask *)launchedTaskWithLaunchPath:(NSString *)path 
                             arguments:(NSArray<NSString *> *)arguments; 

class func launchedProcess(launchPath path: String, 
                 arguments: [String]) -> Process

There seemingly are no replacements available, so what gives?

like image 281
l'L'l Avatar asked Nov 15 '17 18:11

l'L'l


1 Answers

There seemingly are no replacements available

There are, the API is now URL related

Instance Properties

@property(copy) NSURL *executableURL;
@property(copy) NSURL *currentDirectoryURL;

var executableURL: URL? { get set }
var currentDirectoryURL: URL? { get set }

Instance Methods

- (BOOL)launchAndReturnError:(out NSError * _Nullable *)error;

func run() throws

Type Methods

+ (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
like image 145
vadian Avatar answered Oct 02 '22 18:10

vadian