could you tell me please - which object and which method can i use to fetch information about installed applications on OSX with objective c or macruby?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- back button text does not change
- iOS (objective-c) compression_decode_buffer() retu
- how to find the index position of the ARRAY Where
相关文章
- 现在使用swift开发ios应用好还是swift?
- Visual Studio Code, MAC OS X, OmniSharp server is
- TCC __TCCAccessRequest_block_invoke
- xcode 4 garbage collection removed?
- IntelliJ IDEA can't open projects or add SDK o
- Automator: How do I use the Choose from List actio
- Unable to process app at this time due to a genera
- How can I add media attachments to my push notific
If you meant to list all of GUI apps, you can use Launch Services. For the list of functions, see the reference.
Do not manually list
.app
bundles! It's already done by the system, and you just have to query it. There is a command-line program calledlsregister
atwhich can be used to get the detailed dump of the Launch Service database. This tool is sometimes helpful, but don't depend on that in a shipping program,
As it is a unix-like OS there is no real way of telling what you have installed (unless of course you have control of the other app - then there is a lot of ways of doing this for obvious reasons).
Generally apps get put into /Applications or ~/Applications BUT you can run it from anywhere and not those folders (just like a unix machine)
Use Spotlight via NSMetadataQuery.
You can view the results you'll get using mdfind at the command line:
mdfind "kMDItemContentType == 'com.apple.application-bundle'"
Works like a charm and very very fast.
OS X doesn't really have a notion of "installing an app". OS X applications are self contained bundles that appear in the Finder as a single virtual file. There's no central registry, just a convention that applications are placed in /Applications or ~/Applications for a per user "install".
About the best you can do will be enumerate those directories for their contents, and every ".app" directory you find is an application. It will not be a exhaustive (I often run small apps from e.g. my Desktop if I've just downloaded them).
I moved in a following way:
execute command
system_profiler SPApplicationsDataType -xml
from code. KeySPApplicationsDataType
means that only application data is required.-xml
means that I expect to see xml result for easier parsing.parse result array
Here you can find nice example regarding command execution from code: Execute a terminal command from a Cocoa app
Total code example is looked like following:
You can just call the Apple command-line tool
system_profiler
, e.g.% system_profiler SPApplicationsDataType
For C or Objective-C you could use
system()
to do this.For more info:
% man system
% man system_profiler