OGeek|极客世界-中国程序员成长平台

标题: ios - 我可以在 info.plist 中定义用户定义的 key 吗 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 15:55
标题: ios - 我可以在 info.plist 中定义用户定义的 key 吗

我可以用给定名称“SomeKey”定义一个用户定义的键,我可以使用 [[NSBundle mainBundle] objectForInfoDictionaryKey"SomeKey"]

访问



Best Answer-推荐答案


当然!

Apple 文档:

Custom Keys

iOS and macOS ignore custom keys you include in an Info.plist file. If you want to include app-specific configuration information in your Info.plist file, you can do so freely as long as your key names do not conflict with the ones Apple uses. When defining custom key names, prefix them with a unique prefix, such as your app’s bundle ID or your company’s domain name, to prevent conflicts.

您可以通过执行以下操作来获得值(value):

Objective-C

[[NSBundle mainBundle].infoDictionary objectForKey"SomeKey"];

[[NSBundle mainBundle] objectForInfoDictionaryKey"SomeKey"];

swift

Bundle.main.infoDictionary?["SomeKey"]

引用:

Info Plist Docs

Reserved Keys

关于ios - 我可以在 info.plist 中定义用户定义的 key 吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48819534/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4