[英]how can I change custom Info.plist key with simple string
I wanna add a custom key to info.plist
file but **Apple**
says it should be unique.我想在info.plist
文件中添加一个自定义键,但**Apple**
说它应该是唯一的。 so I add the key as **NSCustomKeyName**
or **ZSCustomKeyName**.
所以我将密钥添加为**NSCustomKeyName**
或**ZSCustomKeyName**.
but it should be read "Custom Key"
when I do Open As->Property
List.但是当我打开As->Property
List 时,它应该被读取为"Custom Key"
。 but it stays same as **NSCustomKeyName**
or **ZSCustomKeyName**
.但它与**NSCustomKeyName**
或**ZSCustomKeyName**
相同。 how can I do that?.我怎样才能做到这一点?。 I mean how can I convert **CFBundleName**
key to **" Bundle name"**
.我的意思是如何将**CFBundleName**
键转换为**" Bundle name"**
。
The key-name / Property List name "translation" is done by Xcode via an internal lookup table.键名/属性列表名称“翻译”由 Xcode 通过内部查找表完成。 It's not simply a "strip the prefix and put spaces before upper-case letters" process.这不仅仅是一个“去掉前缀并在大写字母前放置空格”的过程。
For example, when viewing as source, you may have this key:例如,当作为源查看时,您可能有这个键:
<key>NSCameraUsageDescription</key>
which, when viewed as a Property List shows as:其中,当作为属性列表查看时,显示为:
Privacy - Camera Usage Description
If you want to add your own "custom" keys, you are not required to use a prefix... that's just an easy way to make sure they're unique.如果您想添加自己的“自定义”键,则不需要使用前缀......这只是确保它们唯一的一种简单方法。
For example, source view:例如,源视图:
<key>My Key</key>
<string>My Value</string>
will show in Property List view as:将在属性列表视图中显示为:
My Key | My Value
and can be accessed with:并且可以通过以下方式访问:
Bundle.main.infoDictionary?["My Key"]
If I prefix that as:如果我将其前缀为:
com.donmag.My Key
That's how it will show up in Property List view, and I would have to access it with:这就是它在属性列表视图中的显示方式,我必须通过以下方式访问它:
Bundle.main.infoDictionary?["com.donmag.My Key"]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.