獲取應用程序信息.h

//
//  獲取應用程序信息.h
//  IOS筆記
//

通常會用來判斷是否有新版本、是否須要強制更新

iOS的版本號,一個叫作Version,一個叫作Build,這兩個值均可以在Xcode 中選中target,點擊「Summary」後看到。 Version在plist文件中的key是「CFBundleShortVersionString」,和AppStore上的版本號保持一致,Build在plist中的key是「CFBundleVersion」,表明build的版本號,該值每次build以後都應該增長1。這兩個值均可以在程序中經過下面的代碼得到:

[[[NSBundle mainBundle] infoDictionary] valueForKey:@"key"]


[2]具體實現
代碼實現得到應用的Verison號:
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]或[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
得到build號:
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]



打印出來infoDictionary的內容
    NSLog(@"%@",[[NSBundle mainBundle]infoDictionary]);
{
    BuildMachineOSBuild = 15B42;
    CFBundleDevelopmentRegion = en;
    CFBundleExecutable = "UIApplication\U7684\U4f7f\U7528";
    CFBundleIdentifier = "cn.juzhong.UIApplication---";
    CFBundleInfoDictionaryVersion = "6.0";
    CFBundleInfoPlistURL = "Info.plist -- file:///Users/liuweicheng/Library/Developer/CoreSimulator/Devices/1A2BA12B-DF68-48F4-995A-C6AC2701D3AE/data/Containers/Bundle/Application/1543AEC3-3B92-4282-896E-C3A1D8E99E33/UIApplication%E7%9A%84%E4%BD%BF%E7%94%A8.app/";
    CFBundleName = "UIApplication\U7684\U4f7f\U7528";
    CFBundleNumericVersion = 16809984;
    CFBundlePackageType = APPL;
    CFBundleShortVersionString = "1.0";
    CFBundleSignature = "????";
    CFBundleSupportedPlatforms =     (
                                      iPhoneSimulator
                                      );
    CFBundleURLTypes =     (
                            {
                                CFBundleURLName = "";
                            }
                            );
    CFBundleVersion = 1;
    DTCompiler = "com.apple.compilers.llvm.clang.1_0";
    DTPlatformBuild = "";
    DTPlatformName = iphonesimulator;
    DTPlatformVersion = "9.1";
    DTSDKBuild = 13B137;
    DTSDKName = "iphonesimulator9.1";
    DTXcode = 0711;
    DTXcodeBuild = 7B1005;
    LSRequiresIPhoneOS = 1;
    MinimumOSVersion = "9.1";
    NSAppTransportSecurity =     {
        NSAllowsArbitraryLoads = 1;
    };
    UIDeviceFamily =     (
                          1
                          );
    UILaunchStoryboardName = LaunchScreen;
    UIMainStoryboardFile = Main;
    UIRequiredDeviceCapabilities =     (
                                        armv7
                                        );
    UISupportedInterfaceOrientations =     (
                                            UIInterfaceOrientationPortrait,
                                            UIInterfaceOrientationLandscapeLeft,
                                            UIInterfaceOrientationLandscapeRight
                                            );
}




iOS獲取AppStore內應用程序信息

參考 apple的文檔:www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html

具體步驟以下:

1,用 POST 方式發送請求:

http://itunes.apple.com/search?term=你的應用程序名稱&entity=software

更加精準的作法是根據 app 的 id 來查找:

http://itunes.apple.com/lookup?id=你的應用程序的ID

/*
AFHTTPRequestOperationManager *mgr = [AFHTTPRequestOperationManager manager];

mgr.responseSerializer = [AFJSONResponseSerializer serializer];

mgr.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/javascript"];

NSLog(@"xxx");

//發送POST請求
[mgr POST:@"http://itunes.apple.com/search?term=QQ&entity=software" parameters:nil  success:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSLog(@"%@",responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"%@",error);
}];

AFHTTPRequestOperationManager *mgr1 = [AFHTTPRequestOperationManager manager];
mgr1.responseSerializer = [AFJSONResponseSerializer serializer];
mgr1.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/javascript"];
NSLog(@"xxx");
//發送POST請求
[mgr1 POST:@"http://itunes.apple.com/lookup?id=com.tenpay.mobile.iphone" parameters:nil  success:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSLog(@"%@",responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    
    NSLog(@"%@",error);
}];
}
*/


javascript

相關文章
相關標籤/搜索