Defining keywords for dynamic configuration values
For all string type values in , you can specify special keywords in the value string to cause the app to find the value in string resources or in settings. This task demonstrates specifying the title and icon for a custom menu item in the app's sidebar menu.
About this task
Note: You can customize
most settings in Xcode, in
.
Edit the key and value pairs in the
Property List view. Optionally, you can edit the
XML directly in the
Source Code view. To work in the XML view, right
click the file name, and then click
.
Procedure
Example: defining a custom menu item
The following example demonstrates defining a custom menu item.
- In the app file
Localizable.strings, we defined these string
resources.
"my_menuitem_icon1_filename" = "test_menuitem_icon1.png"; "my_menuitem_icon1selected_filename" = "test_menuitem_icon1_active.png"; - In
,
in the
Property
List view,
find and expand the key labeled
CustomMenuItems. - Add the following entries.
Key Type Value CustomMenuItems Array (2 items) Item 0 Dictionary (4 items) icon String string: my_menuitem_icon1_filenameiconSelected String string: my_menuitem_icon1selected_filenametitle String setting: my_test_menuitem1_titleurl String https://spotfi.reNote: In the Source Code view, this section is displayed as follows.<dict> <key>icon</key> <string>string: my_menuitem_icon1_filename</string> <key>iconSelected</key> <string>string: my_menuitem_icon1selected_filename</string> <key>title</key> <string>setting: my_test_menuitem1_title</string> <key>url</key> <string>https://spotfi.re</string> </dict> - In the Xcode project navigator, find and open .
- In the
Property
List view,
find the setting
Text Field - My Custom Menu Item Title.Key Type Value Item 19 (Text Field - My Custom Menu Item Title) Dictionary (4 items) Default Value String My Custom Menu Item 1Identifier String my_test_menuitem1_titleTitle String My Custom Menu Item TitleType String Text FieldNote: In the Source Code view, this section is displayed as follows.<dict> <key>DefaultValue</key> <string>My Custom Menu Item 1</string> <key>Key</key> <string>my_test_menuitem1_title</string> <key>Title</key> <string>My Custom Menu Item Title</string> <key>Type</key> <string>PSTextFieldSpecifier</string> </dict>
- Security considerations
Remember that when you build the app into a package for distribution with Xcode, string resources for the app are in clear text.
Parent topic: Customize app behavior
Related concepts
Related tasks
Related reference