加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-14 17:29:26 所属栏目:百科 来源:网络整理
导读:我正在尝试在 Xcode中创建自定义模板.在我的TemplateInfo.plist中,对于键选项,我将代码粘贴在下面.此模板将用于一个类,当事件发生时,通常会(但不总是)使用委托. 我遇到的问题是最底层的值,RequiredOptions.我希望只有选中withProtocol复选框才能启用文本框.
我正在尝试在 Xcode中创建自定义模板.在我的TemplateInfo.plist中,对于键选项,我将代码粘贴在下面.此模板将用于一个类,当事件发生时,通常会(但不总是)使用委托.

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

>< true /> (如下所示) – 始终启用文本框.
>< string> YES< / string> – 始终禁用文本框.
><整数> 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>.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读