获取应用程序信息.h
//
//? 獲取應(yīng)用程序信息.h
//? IOS筆記
//
一般會(huì)用來(lái)判斷是否有新版本、是否需要強(qiáng)制更新
iOS的版本號(hào),一個(gè)叫做Version,一個(gè)叫做Build,這兩個(gè)值都可以在Xcode 中選中target,點(diǎn)擊“Summary”后看到。 Version在plist文件中的key是“CFBundleShortVersionString”,和AppStore上的版本號(hào)保持一致,Build在plist中的key是“CFBundleVersion”,代表build的版本號(hào),該值每次build之后都應(yīng)該增加1。這兩個(gè)值都可以在程序中通過(guò)下面的代碼獲得:
[[[NSBundle mainBundle] infoDictionary] valueForKey:@"key"]
[2]具體實(shí)現(xiàn)
代碼實(shí)現(xiàn)獲得應(yīng)用的Verison號(hào):
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]或[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
獲得build號(hào):
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]
打印出來(lái)infoDictionary的內(nèi)容
??? 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內(nèi)應(yīng)用程序信息
參考 apple的文檔:www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html
具體步驟如下:
1,用 POST 方式發(fā)送請(qǐng)求:
http://itunes.apple.com/search?term=你的應(yīng)用程序名稱&entity=software
更加精準(zhǔn)的做法是根據(jù) app 的 id 來(lái)查找:
http://itunes.apple.com/lookup?id=你的應(yīng)用程序的ID
/*
AFHTTPRequestOperationManager *mgr = [AFHTTPRequestOperationManager manager];
mgr.responseSerializer = [AFJSONResponseSerializer serializer];
mgr.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/javascript"];
NSLog(@"xxx");
//發(fā)送POST請(qǐng)求
[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");
//發(fā)送POST請(qǐng)求
[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);
}];
}
*/
轉(zhuǎn)載于:https://www.cnblogs.com/er-dai-ma-nong/p/5045703.html
總結(jié)
以上是生活随笔為你收集整理的获取应用程序信息.h的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: hp
- 下一篇: SVN需要忽略的文件类型