It is mainly used for program upgrade, whether to show the new features two aspects after opening the program.
1. Apple app version
Apple rules that the version of the program can only rise and fall. For example 1.0->1.1 can, 1.1->1.0 can not, do not allow shelves.
2.app Version Storage location
The version information is stored in the Info.plist file and can be seen in the general section of the project. When the app is updated, the version information here is automatically modified, so getting the version information in Info.plist is the latest version. If you want to artificially modify them at any point in both places.
3. Code implementation (Swift)
The last version is saved in the sandbox and then compared to the latest. The implementation is as follows:
1 ///returns True if the program has just been updated2 PrivateFunc isupdated ()Bool {3 4 //get the current version of the program from Info.plist5Let Currentversionstr = Nsbundle.mainbundle (). infodictionary! ["cfbundleshortversionstring"] as!String6Let CurrentVersion = Nsnumberformatter (). numberfromstring (CURRENTVERSIONSTR)!. Doublevalue7 8 //get the version in the sandbox9Let Versionkey ="Sandboxkey"TenLet Userdefaults =nsuserdefaults.standarduserdefaults () OneLet sandboxversion =Userdefaults.doubleforkey (Versionkey) A - //record the current version into a sandbox - userdefaults.setdouble (CurrentVersion, Forkey:versionkey) the userdefaults.synchronize () - - //returns true only if it is greater than - returnCurrentVersion >sandboxversion +}
How iOS knows the app version has been updated