在 Xcode 中创建自定义模板 - 如何根据复选框创建必需选项?

mbu*_*c91 6 xcode cocoa-touch templates plist ios

我正在尝试在 Xcode 中创建一个自定义模板。在我的 TemplateInfo.plist 中,对于关键选项,我粘贴了下面的代码。此模板将用于在事件发生时经常(但并非总是)使用委托的类。

我遇到的问题是最底部的值RequiredOptions. 我希望只有在选中 withProtocol 复选框时才启用文本框。但是,我无法弄清楚要使用什么值和值类型。我尝试了以下方法:

  • <true/> (如下) - 文本框始终处于启用状态。
  • <string>YES</string> - 文本框始终处于禁用状态。
  • <integer>1</integer> - 文本框始终处于启用状态。

有没有人对我可以尝试的其他方法有任何想法?更好的是,有人知道 Xcode 模板的体面参考吗?

我已经通读了 Apple 的 plist 手册页和本网站上的文章。

<array>
    <dict>
        <key>Description</key>
        <string>The name of the class to create</string>
        <key>Identifier</key>
        <string>productName</string>
        <key>Name</key>
        <string>Class</string>
        <key>NotPersisted</key>
        <true/>
        <key>Required</key>
        <true/>
        <key>Type</key>
        <string>text</string>
    </dict>
    <dict>
        <key>Default</key>
        <string>false</string>
        <key>Identifier</key>
        <string>withXIB</string>
        <key>Name</key>
        <string>With XIB for user interface</string>
        <key>Type</key>
        <string>checkbox</string>
    </dict>
    <dict>
        <key>Description</key>
        <string>Choose whether or not a delegate skeleton is included.</string>
        <key>Default</key>
        <string>false</string>
        <key>Identifier</key>
        <string>withProtocol</string>
        <key>Name</key>
        <string>With delegate skeleton</string>
        <key>Type</key>
        <string>checkbox</string>
    </dict>
    <dict>
        <key>Description</key>
        <string>The name of the protocol used for delegation.</string>
        <key>Identifier</key>
        <string>protocolName</string>
        <key>Name</key>
        <string>Protocol</string>
        <key>NotPersisted</key>
        <true/>
        <key>Required</key>
        <true/>
        <key>Type</key>
        <string>text</string>
        <key>RequiredOptions</key>
        <dict>
            <key>withProtocol</key>
            <true/>
        </dict>
    </dict>
</array>
Run Code Online (Sandbox Code Playgroud)

mbu*_*c91 3

<true/>我通过替换为解决了我自己的问题<string>true</string>