在app运行的时候,需要读取info.plist中的信息,用以下代码可获取整个info.plist的信息

[[NSBundle mainBundle] infoDictionary]

以下为根据 key 值去取 URLTypes 里面对应的值:

+ (NSString *)URLSchemesForkey:(NSString *)key {

    NSDictionary *dict = [[NSBundle mainBundle] infoDictionary];
NSArray *urlTypes = dict[@"CFBundleURLTypes"];
NSString *urlSchemes = nil;
for (NSDictionary *scheme in urlTypes) {
NSString *schemeKey = scheme[@"CFBundleURLName"];
if ([schemeKey isEqualToString:key]) {
urlSchemes = scheme[@"CFBundleURLSchemes"][];
break;
}
}
return urlSchemes;
}

info.plist所有的信息,示例如下:

{
"" = "";
BuildMachineOSBuild = 16G1114;
CFBundleDevelopmentRegion = "zh_CN";
CFBundleDisplayName = "xxxx";
CFBundleExecutable = Ronghemt;
CFBundleIcons = {
CFBundlePrimaryIcon = {
CFBundleIconFiles = (
AppIcon20x20,
AppIcon29x29,
AppIcon40x40,
AppIcon60x60
);
CFBundleIconName = AppIcon;
};
};
CFBundleIdentifier = "xxxx";
CFBundleInfoDictionaryVersion = "6.0";
CFBundleName = xxx;
CFBundleNumericVersion = 0;
CFBundlePackageType = APPL;
CFBundleShortVersionString = "2.xxx";
CFBundleSupportedPlatforms = (
iPhoneOS
);
CFBundleURLTypes = (
{
CFBundleTypeRole = Editor;
CFBundleURLName = WX;
CFBundleURLSchemes = (
xxx
);
},
{
CFBundleTypeRole = Editor;
CFBundleURLName = xxx;
CFBundleURLSchemes = (
"xxx"
);
},
{
CFBundleTypeRole = Editor;
CFBundleURLName = tencent;
CFBundleURLSchemes = (
xxx
);
},
{
CFBundleTypeRole = Editor;
CFBundleURLName = QQ;
CFBundleURLSchemes = (
xxx
);
},
{
CFBundleTypeRole = Editor;
CFBundleURLName = xxxx;
CFBundleURLSchemes = (
xxxxxx
);
}
);
CFBundleVersion = "180119.001";
DTCompiler = "com.apple.compilers.llvm.clang.1_0";
DTPlatformBuild = 15C107;
DTPlatformName = iphoneos;
DTPlatformVersion = "11.2";
DTSDKBuild = 15C107;
DTSDKName = "iphoneos11.2";
DTXcode = 0920;
DTXcodeBuild = 9C40b;
LSApplicationQueriesSchemes = (
wechat,
weixin,
sinaweibohd,
sinaweibo,
sinaweibosso,
weibosdk,
"weibosdk2.5",
mqqapi,
mqq
);
LSRequiresIPhoneOS = 1;
MinimumOSVersion = "8.0";
NSAppTransportSecurity = {
NSAllowsArbitraryLoads = 1;
NSAllowsArbitraryLoadsInWebContent = 1;
};
NSCameraUsageDescription = "\U9700\U8981\U8bbf\U95ee\U60a8\U7684\U76f8\U673a\U8fdb\U884c\U62cd\U6444";
NSPhotoLibraryUsageDescription = "\U9700\U8981\U8bbf\U95ee\U60a8\U7684\U76f8\U518c\U83b7\U53d6\U56fe\U7247";
UIDeviceFamily = (
1
);
UILaunchImages = (
{
UILaunchImageMinimumOSVersion = "8.0";
UILaunchImageName = "LaunchImage-800-Portrait-736h";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{414, 736}";
},
{
UILaunchImageMinimumOSVersion = "8.0";
UILaunchImageName = "LaunchImage-800-667h";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{375, 667}";
},
{
UILaunchImageMinimumOSVersion = "7.0";
UILaunchImageName = "LaunchImage-700";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{320, 480}";
},
{
UILaunchImageMinimumOSVersion = "7.0";
UILaunchImageName = "LaunchImage-700-568h";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{320, 568}";
}
);
UIRequiredDeviceCapabilities = (
arm64
);
UIStatusBarStyle = UIStatusBarStyleLightContent;
UISupportedInterfaceOrientations = (
UIInterfaceOrientationPortrait,
UIInterfaceOrientationLandscapeLeft,
UIInterfaceOrientationLandscapeRight
);
}

iOS读取info.plist中的值的更多相关文章

  1. Eclipse RCP 中创建自己定义首选项,并能读取首选项中的值

    Eclipse RCP的插件中若想自定义首选项须要扩展扩展点: org.eclipse.core.runtime.preferences //该扩展点用于初始化首选项中的值 org.eclipse.u ...

  2. iOS项目Info.plist中关键字汇总

    1. Application does not run in background (键名:UIApplicationExistsOnSuspend) 自从iOS4.0之后,当你在应用程序执行的时候按 ...

  3. 前后台读取Web.config中的值的方法

    webconfig <configuration> <appSettings> <add key="Workflow_Url" value=" ...

  4. Spring中使用@Value读取porperties文件中的属性值方法总结及注意事项

    本文为博主原创,转载请注明出处. 此前曾总结过使用工具类读取properties文件中的属性值,有兴趣的可以看一下. 如何快速获取properties中的配置属性值:https://www.cnblo ...

  5. 封装的方法--读取任何路径下的properties文件中的值

    概述:我们在做项目时,经常需要从某个properties文件中读取properties文件中的值.现在我封装了一下方法,直接读取配置文件中的值. 代码如下所示: /** * Created by qi ...

  6. [原创]java WEB学习笔记59:Struts2学习之路---OGNL,值栈,读取对象栈中的对象的属性,读取 Context Map 里的对象的属性,调用字段和方法,数组,list,map

    本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...

  7. ios 访问隐私信息 info.plist 中的字段

    1.iOS10相册相机闪退bug: iOS10系统下调用系统相册,相机功能,遇到闪退的情况,描述如下: This app has crashed because it attempted to acc ...

  8. java中Properties类及读取properties中属性值

    本文为博主原创,未经允许不得转载: 在项目的应用中,经常将一些配置放入properties文件中,在代码应用中读取properties文件,就需要专门的类Properties类,通过这个类可以进行读取 ...

  9. C#读取注册表中二进制类型的值(REG_BINARY)

    如需要读取注册表中某个键的值, 例如读取DriverDesc对应的值,一般情况下为String类型,读取代码如下: RegistryKey driverKey = Registry.LocalMach ...

随机推荐

  1. 2-2 Sass的函数功能-字符串与数字函数

    Sass的函数简介 在 Sass 中除了可以定义变量,具有 @extend.%placeholder 和 mixins 等特性之外,还自备了一系列的函数功能.其主要包括: 字符串函数 数字函数 列表函 ...

  2. 关于tr:hover变色的问题

    最近在给table里面的tr标签添加高亮背景色显示的时候,遇到一个坑,HTML结构如下: <tr> <td></td> <td></td> ...

  3. Android setTag()/getTag()

    View中的setTag(Onbect)表示给View添加一个格外的数据,以后可以用getTag()将这个数据取出来. 可以用在多个Button添加一个监听器,每个Button都设置不同的setTag ...

  4. qt 使用qtxlsx 读写excel

    https://github.com/dbzhang800/QtXlsxWriter 下载qtxlsx地址 QtXlsx is a library that can read and write Ex ...

  5. 阿里云安装jdk报错gzip: stdin: unexpected end of file

    在阿里云上面安装jdk时候报了这个问题,如下图所示 然后看了下jdk应该是有150多M的,但是阿里云上面的只有1M多,删除 重新下载... tar zxvf jdk 好了

  6. SQL Server ->> T-SQL查询面试题之实例版

    1 - 3 题: 数据表结构: OrderID ProductID OrderDate  SaleAmount 1 1 2015-01-01 100 2 6  2015-02-01 900 3 1   ...

  7. 【Leetcode】【Easy】Merge Two Sorted Lists .

    Merge two sorted linked lists and return it as a new list. The new list should be made by splicing t ...

  8. 【Leetcode】【Medium】3Sum

    Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all un ...

  9. UIScrollView中的手势

    UIScrollView中的手势 UIScrollView自带了两个手势,分别为: UIPanGestureRecognizer UIPinchGestureRecognizer 他们都是readon ...

  10. php红包生成随机算法

    一.适用场景 红包总金额X,分配成Y个红包,每个红包随机金额. 二.生成算法 /** * 红包生成算法 * @param $money 总金额 * @param $number 红包数量 * @par ...