Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use canOpenURL in mac OS application?

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?

like image 994
user3745888 Avatar asked Sep 19 '25 23:09

user3745888


1 Answers

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

like image 164
Cee Avatar answered Sep 22 '25 14:09

Cee