[英]Comments in plist file
我想将所有api保存到plist文件。 绝对是键值对。 密钥是类似于1001的数字,值是api路径字符串。 我需要为每个api对添加注释,以使其他开发人员容易阅读它。 我知道<!-- comments -->
样式注释可以在plist源文件中完成,但是您知道我想使注释出现在plist文件中(不在文件源代码中),就像在Xcode中打开一样。 看到:
有可能吗
这是不可能的,因为任何读取XML的代码(例如[NSDictionary dictionaryWithContentsOfFile:]
)都将丢弃<!-- ... -->
[NSDictionary dictionaryWithContentsOfFile:]
<!-- ... -->
注释。
使它们持久的唯一方法是使注释成为所存储数据的一部分。
创建API对象作为字典,并添加一个可读的注释对象!
您可以更改plist文件的结构。 例如:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>content</key>
<array>
<dict>
<key>coment</key>
<string>the things you want to say</string>
<key>2001</key>
<string>image/%@</string>
</dict>
<dict>
<key>comment</key>
<string>the things you want to say</string>
<key>1001</key>
<string>image////</string>
</dict>
</array>
<key>comment</key>
<string>your comment</string>
</dict>
</plist>
抱歉,我无法上传图片。
您可以借助存储在/Developer/Applications/Utilities
或/DevTools/Application//Utilities
下的Apple的“ Property List Editor
以交互方式将注释(使用Comment
或任何您想用作关键字的Comment
)添加(并编辑)到现有plist文件中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.