小编Oha*_*adM的帖子

使用自定义模板xcode 8创建组

我已经成功创建了一个响应这些操作的Xcode 8模板:

  1. 你已经有了一个工作项目
  2. 您想将自定义swift文件添加到此项目中

一步一步,如何实现:

我创建于:

/Users/*YOUR_USER_NAME*/Library/Developer/Xcode/Templates/File Templates
Run Code Online (Sandbox Code Playgroud)

文件夹名称 Custom/Interactor.xctemplate

该文件夹中的文件:

  • ___FILEBASENAME___Interactor
  • TemplateInfo.plist
  • TemplateIcon.png
  • TemplateIcon@2x.png

因此,当我右键单击并创建新文件时,我将选择自定义文件:

创建新文件

创建自定义文件

上面的示例工作并创建我的自定义文件:

成功创建自定义文件

我想要实现的目标:

我正在尝试创建一个包含新自定义文件的组.不需要实际的文件夹或复杂的任务,只需要包含实际文件的组.

所以最终结果将是:

在此输入图像描述

由于没有解释如何创建自定义模板的文档,我使用了很多引用:ref1,ref2,ref3,ref4.

这是TemplateInfo.plist文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>DefaultCompletionName</key>
    <string>MyCustomInteractor</string>
  <key>Description</key>
  <string>Custom interactor</string>
  <key>Kind</key>
  <string>Xcode.IDEKit.TextSubstitutionFileTemplateKind</string>
  <key>Options</key>
  <array>
        <dict>
            <key>Description</key>
            <string>Custom interactor</string>
            <key>Identifier</key>
            <string>fileName</string>
            <key>Name</key>
            <string>Custom name</string>
            <key>NotPersisted</key>
            <true/>
            <key>Required</key>
            <true/>
            <key>Type</key>
            <string>text</string>
        </dict>
    <dict>
            <key>Default</key>
            <string>___VARIABLE_fileName:identifier___</string>
            <key>Identifier</key>
            <string>productName</string>
            <key>Type</key>
            <string>static</string>
    </dict>
    <dict>
            <key>Default</key> …
Run Code Online (Sandbox Code Playgroud)

xcode templates xcode-template xcode8

15
推荐指数
1
解决办法
3016
查看次数

将Integer []转换为int []的最佳方法是什么?

将Integer数组转换为int数组的最佳方法是什么?

它的简单解决方案是:

public int[] toPrimitiveInts(Integer[] ints) {
    int[] primitiveInts = new int[ints.length];
    for(int i = 0; i < ints.length; i++) {
        primitiveInts[i] = ints[i] == null ? 0 : ints[i];
    }
    return primitiveInts;
}
Run Code Online (Sandbox Code Playgroud)

在上面的例子中,我采用0null对象/包装器的默认值为null并且int为0这一事实的值.

这个答案显示了如何将int []转换为Integer []

但我找不到将Integer []转换为int []的简单方法.

java arrays

7
推荐指数
1
解决办法
153
查看次数

标签 统计

arrays ×1

java ×1

templates ×1

xcode ×1

xcode-template ×1

xcode8 ×1