我正在尝试在 Xcode 中创建自定义模板。在我的 TemplateInfo.plist 中,对于关键选项,我在下面粘贴了代码。此模板适用于在事件发生时经常(但不总是)使用委托(delegate)的类。
我遇到的问题是最底部的值,RequiredOptions
.我希望仅当选中 withProtocol 复选框时才启用文本框。但是,我无法弄清楚要使用什么值(value)和值(value)类型。我尝试了以下方法:
-
<true/>
(如下所示)- 文本框始终处于启用状态。 -
<string>YES</string>
- 文本框始终处于禁用状态。 -
<integer>1</integer>
- 文本框始终处于启用状态。
有人对我还可以尝试什么有任何想法吗?更好的是,有人知道 Xcode 模板的不错引用吗?
我已经通读了 Apple 的 plist 手册页和文章 this website .
<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>
最佳答案
我通过替换 <true/>
解决了我自己的问题与 <string>true</string>
.
关于ios - 在 Xcode 中创建自定义模板 - 如何根据复选框创建所需的选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14883506/