IOS Get AppStore version number

Source: Internet
Author: User

After the project is on-line generally involves upgrading, then iOS how to get the version number from AppStore


Actually, it's simple.

    NSString *url = [[NSString alloc] initwithformat:@ "http://itunes.apple.com/lookup?id=%@", @ "987953868"];

The last number in the list is the unique ID of the current app. How to get this ID, Baidu a bit simple


Then we just need to call this address and we'll return some information about the current app, including the version number on AppStore (provided the project is online to AppStore)


We're going to get the process done and we'll just call the address directly using this method.

    Get AppStore version number    nsstring *url = [[NSString alloc] initwithformat:@ "http://itunes.apple.com/lookup?id=%@", @ " 987953868 "];            [Self postpath:url];



#pragma mark--Get data-(void) Postpath: (NSString *) path{nsurl *url = [Nsurl Urlwithstring:path];                                                           Nsmutableurlrequest *request = [Nsmutableurlrequest requestwithurl:url Cachepolicy:nsurlrequestreloadignoringcachedata Timeoutinterv        AL:10];            [Request sethttpmethod:@ "POST"];        Nsoperationqueue *queue = [Nsoperationqueue new]; [Nsurlconnection sendasynchronousrequest:request queue:queue completionhandler:^ (NSURLResponse *response,NSData *        Data,nserror *error) {nsmutabledictionary *receivestatusdic=[[nsmutabledictionary alloc]init]; if (data) {nsdictionary *receivedic = [Nsjsonserialization jsonobjectwithdata:data Options:nsjsonr            Eadingmutableleaves Error:nil]; if ([[Receivedic valueforkey:@ "Resultcount"] intvalue]>0) {[Receivestatusdic setvalue:@    "1" forkey:@ "status"];            [Receivestatusdic setvalue:[[[receivedic valueforkey:@ "results"] objectatindex:0] valueforkey:@ "version"] fo            rkey:@ "Version"];            }else{[Receivestatusdic setvalue:@ "-1" forkey:@ "status"];        }}else{[Receivestatusdic setvalue:@ "-1" forkey:@ "status"];    } [Self Performselectoronmainthread: @selector (receivedata:) withobject:receivestatusdic Waituntildone:no]; }];}

-(void) Receivedata: (ID) sender{    NSLog (@ "receivedata=%@", sender);    }

The final printed dictionary contains the version number


receivedata={

status = 1;

Version = "1.0.0";

}



Okay, what's the problem? Welcome Dabigatran Discussion

Apple Development Group: 414319235 Welcome to join the Welcome discussion question


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

IOS Get AppStore version number

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.