简体   繁体   中英

Cocoa application reinstall

I would like to detect if my application was "reinstalled". Currently my application install means only a copy to the /Applications folder.

I would like to detect if somebody deleted the application and after a time he installed it again.

Do you have any ideas how can this be solved?

I would like to detect if somebody deleted

You can use FNSubscribeByPath (Deprecated in OS X v10.8.) for watching trash folder.

I would like to detect if my application was "reinstalled"

You can create one file in application support (your application folder) folder and refer that file. Write application version number in that file.

Your app is just a folder on HDD/SSD, so user can manipulate it like usual file. User can put your app in ~/Applications/MyStuff, make 300 copies of your app and launch them at once.

The only thing you can check is the bundle version of app. Read version from user defaults (written by previous app lauch) and compare to your own bundle version. This may be useful for updates to detect which resources can be upgraded or created.

How about checking for an existing preferences file or expected user defaults setting?

That would give you some hint it was installed recently - few people clean up their preferences folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM