Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a custom template in Xcode - how can I make a required option based on a checkbox?

I am trying to create a custom template in Xcode. In my TemplateInfo.plist, for key Options, I have the code pasted below. This template will be for a class that more often than not (but not always) will use delegation when events occur.

The issue I am having is with the value at the very bottom, RequiredOptions. I want the text box to be enabled only if the withProtocol checkbox is checked. However, I can't figure out what value and type of value to use. I have tried the following:

  • <true/> (as below) - The text box is always enabled.
  • <string>YES</string> - The text box is always disabled.
  • <integer>1</integer> - The text box is always enabled.

Does anyone have any ideas for what else I could try? Better yet, does anyone know of a decent reference for Xcode templates?

I have already read through Apple's plist manual pages and the article at 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>
like image 685
mbuc91 Avatar asked Feb 14 '13 20:02

mbuc91


1 Answers

I fixed my own problem by replacing <true/> with <string>true</string>.

like image 68
mbuc91 Avatar answered Oct 02 '22 00:10

mbuc91