Post

Replies

Boosts

Views

Activity

-[NSWorkspace openApplicationAtURL:configuration:completionHandler:] does not work
There is a LoginItem in my app that launches the application. It works fine with approximately the following code snippet:     NSBundle* bundle = NSBundle.mainBundle;     NSWorkspace* workspace = NSWorkspace.sharedWorkspace;     NSString* path = bundle.bundlePath;     for (int i = 0; i < 4; ++i) {       path = [path stringByDeletingLastPathComponent];     }     NSDictionary* configuration = @{ NSWorkspaceLaunchConfigurationEnvironment: env };     NSError* error = nil;     [workspace launchApplicationAtURL: [NSURL fileURLWithPath: path] options: NSWorkspaceLaunchDefault configuration: configuration error: &error];     if (error) {       NSLog(@"Failed to run the app: %@", error.localizedDescription);     } Since 11.0, launchApplicationAtURL: is deprecated in favour of openApplicationAtURL:. When I try to use it instead, the application does not start at all and no error is reported. What am I doing wrong? The new code looks like this:     NSWorkspaceOpenConfiguration* configuration = [NSWorkspaceOpenConfiguration configuration];     [configuration setEnvironment: env];     [configuration setPromptsUserIfNeeded: YES];     [workspace openApplicationAtURL: [NSURL fileURLWithPath: path] configuration: configuration completionHandler:^(NSRunningApplication* app, NSError* error) {       if (error) {         NSLog(@"Failed to run the app: %@", error.localizedDescription);       }     }];
1
0
1.5k
Nov ’20
NSToolbarItem.minSize and NSToolbarItem.maxSize methods are deprecated
How to get rid of this warning? NSToolbarItem.minSize and NSToolbarItem.maxSize methods are deprecated. I do not set minSize or maxSize, it is Interface Builder that seems to do this. Even if I create completely new interface from scratch, this warning still appears. What is the point of introducing this warning if Apple tools unable to produce correct behaviour?
8
0
4.5k
Nov ’20
How to get the number of high-performance cores on Apple Silicon?
I have the legacy app that maintain its own thread pool to do cpu intensive work. It uses NSProcessInfo.processInfo.activeProcessorCount to get number cores and max thread pool size. It worked quite fine for Intel-based Macs but for Apple Silicon Macs it does not make much sense to create more threads than there are high-performance cores. How do I get the number of high-performance cores on Apple Silicon Macs?
2
0
1.4k
Oct ’20