简体   繁体   中英

Comments in plist file

I want to save all apis to a plist file. Absolutely It's a key-value pair. The key is a number like 1001, and the value is the api path string. What I need is to add a comment for per api pair for other developers feeling easy to read it. I know the <!-- comments --> style comment can be done in the plist source files, but you know I want to make the comments appear in the plist file(not in file source code) what's looks like opening in Xcode. See:

在此处输入图片说明

Is possible?

It's not possible as any code that reads the XML (like [NSDictionary dictionaryWithContentsOfFile:] ) will discard the <!-- ... --> comments.

The only way to make them persist is to make the comments part of the data being stored.

创建API对象作为字典,并添加一个可读的注释对象!

you can change the structure of the plist file. for example:

<?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>

sorry,I can't upload the image.

您可以借助存储在/Developer/Applications/Utilities/DevTools/Application//Utilities下的Apple的“ Property List Editor以交互方式将注释(使用Comment或任何您想用作关键字的Comment )添加(并编辑)到现有plist文件中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM