NSTask / Process deprecated methods and properties
Asked Answered
B

1

13

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?

Bruce answered 15/11, 2017 at 18:49 Comment(0)
C
20

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
Competitive answered 15/11, 2017 at 19:4 Comment(5)
Is there someplace that mentions this change? Thanks!Diane
AFAIR It was mentioned in a WWDC video.Competitive
what WWDC video?Rockbottom
@Rockbottom What's new in Cocoa, WWDC 2017, mentioned in a subclause.Competitive
It's mid 2019 and still the XCode docs don't have any overview or discussion notes. And the deprecated functions don't point to the new APIs to use either. Thanks @Competitive for pointing these out.Okoka

© 2022 - 2024 — McMap. All rights reserved.