IOS checks the new version of the App and updates the new version. ios checks the new version of the app.
Check for new version updates
# Define kStoreAppId @ "xxxxxxxxx" // (appid digital string)/*** check the id of the new version update @ "1081299902" app */-(void) checkAppUpdate {NSDictionary * infoDict = [[NSBundle mainBundle] infoDictionary]; NSString * nowVersion = [infoDict objectForKey: @ "CFBundleVersion"]; NSURL * url = [NSURL encoding: [NSString encoding: @ "http://itunes.apple.com/lookup? Id = % @ ", @" "]; // @" "contains appId For example: @" 1081408739 "NSString * file = [NSString stringWithContentsOfURL: url encoding: NSUTF8StringEncoding error: nil]; nsange substr = [file rangeOfString: @ "\" version \ ": \" "]; nsange range1 = NSMakeRange (substr. location + substr. length, 10); // nsange substr2 = [file rangeOfString: @ "\" "options: nil range: range1]; nsange substr2 = [file rangeOfString: @ "\" "options: NSCaseInsens ItiveSearch range: range1]; nsange range2 = NSMakeRange (substr. location + substr. length, substr2.location-substr. location-substr.length); NSString * newVersion = [file substringWithRange: range2]; if (! [NowVersion isEqualToString: newVersion]) {UIAlertView * alert = [[UIAlertView alloc] initWithTitle: nil message: @ "a new version is available ~~ "Delegate: self cancelButtonTitle: @" cancel "otherButtonTitles: @" going to update ", nil]; [alert show] ;}}-(void) alertView :( UIAlertView *) alertView clickedButtonAtIndex :( NSInteger) buttonIndex {if (buttonIndex = 1) {// Add the address of the application to the app store to facilitate updates. One method is as follows: NSURL * url = [NSURL URLWithString: [NSString stringWithFormat: @ "https://itunes.apple.com/us/app/id%? Ls = 1 & mt = 8 ", @" "]; // @" "contains appId For example: @" 1081408739 "[[UIApplication sharedApplication] openURL: url] ;}}View Code