LoginSignup
9
8

More than 5 years have passed since last update.

すべてのアプリケーションのパス一覧を取得する

Posted at

Core Services の undocumented な関数 _LSCopyAllApplicationURLs を使うと、すべてのアプリケーションのパスを取得できる。

// ヘッダではプロトタイプ宣言されていないので自前で宣言する
void _LSCopyAllApplicationURLs(CFArrayRef *appURLs);

- (NSArray *)allApplicationURLs {
    CFArrayRef appURLs;
    _LSCopyAllApplicationURLs(&appURLs);
    return CFBridgingRelease(appURLs);
}

すべての アプリケーションとは、 /Applications ほかいくつかのシステム標準アプリケーションフォルダに入っているアプリケーションすべてという意味。それ以外のフォルダに入っているアプリケーションは対象にならない。

この関数はシステムにキャッシュされたパスを返すので、アプリケーションフォルダを走査するコードより高速に動作する。

参考にしたページ: AllApplications - CocoaDev

9
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
8