refactor: migrate electron_login_helper
to non-deprecated API (#43182)
refactor: migrate electron_login_helper to non-deprecated API
This commit is contained in:
parent
78995b956e
commit
2a613cabaa
1 changed files with 11 additions and 10 deletions
|
@ -4,12 +4,6 @@
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
// launchApplication is deprecated; should be migrated to
|
|
||||||
// [NSWorkspace openApplicationAtURL:configuration:completionHandler:]
|
|
||||||
// UserNotifications.frameworks API
|
|
||||||
#pragma clang diagnostic push
|
|
||||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
NSArray* pathComponents =
|
NSArray* pathComponents =
|
||||||
|
@ -17,11 +11,18 @@ int main(int argc, char* argv[]) {
|
||||||
pathComponents = [pathComponents
|
pathComponents = [pathComponents
|
||||||
subarrayWithRange:NSMakeRange(0, [pathComponents count] - 4)];
|
subarrayWithRange:NSMakeRange(0, [pathComponents count] - 4)];
|
||||||
NSString* path = [NSString pathWithComponents:pathComponents];
|
NSString* path = [NSString pathWithComponents:pathComponents];
|
||||||
|
NSURL* url = [NSURL fileURLWithPath:path];
|
||||||
|
|
||||||
[[NSWorkspace sharedWorkspace] launchApplication:path];
|
[[NSWorkspace sharedWorkspace]
|
||||||
|
openApplicationAtURL:url
|
||||||
|
configuration:NSWorkspaceOpenConfiguration.configuration
|
||||||
|
completionHandler:^(NSRunningApplication* app, NSError* error) {
|
||||||
|
if (error) {
|
||||||
|
NSLog(@"Failed to launch application: %@", error);
|
||||||
|
} else {
|
||||||
|
NSLog(@"Application launched successfully: %@", app);
|
||||||
|
}
|
||||||
|
}];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -Wdeprecated-declarations
|
|
||||||
#pragma clang diagnostic pop
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue