I had a function to check if chrome could be open an url. In iOS I had:
// is chrome installed??
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"googlechrome://"]])
{
...
}
But now in my app to Mac OS, I can't use this, because is undeclared function with NSWorkspace.
if ([[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"googlechrome://"]])
{
...
}
So, how can use canOpenURL?
Use NSWorkspace
's fullPathForApplication
to get an application's bundle path. If that method returns nil
, the app is not installed.
Related question: how to detect if user has an app in Cocoa
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With