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

标签 ios xcode cocoa-touch templates plist

我正在尝试在 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/

相关文章:

ios - 相机没有响应

xcode - 为 UIButton 设置图像

ios - Swift - 你如何决定你的 iOS 应用程序的最佳 "Deployment Target"

iPhone、XCode 和源代码控制

iphone - 从 UISegmentedControl 中删除白色渐变

ios - 使用大量 IBOutlets 是一种好习惯吗?

ios - "Calibrate"用于 UI 更新的 NSTimer

ios - 使用 UIPageViewController 和 UISegmentedControl 平滑过渡,就像在 Apple Music App 中一样

ios - 存档上传错误 : ERROR ITMS-90207 - The bundle does not contain a bundle executable

ios - 在 iOS 中使用 JSON 发送 HTTP POST 请求