【问题标题】:How to add "Class Prefix" field while creating xcode project template如何在创建 xcode 项目模板时添加“类前缀”字段
【发布时间】:2013-06-01 06:31:42
【问题描述】:

我正在使用已由某人定义的自定义模板。当我使用该模板时,Xcode 不会要求"Class Prefix"。因此,使用此模板创建的任何类都具有作为项目名称的类名,后跟我们提供的类名,如"SampleProjectViewController.h""SampleProjectViewController.m"

有没有办法在创建新类时添加"Class Prefix" 字段并使用此类前缀,这样当我创建新类时,预期的类名将是SPViewController.hSPViewController.m

【问题讨论】:

    标签: ios xcode project-template xcode-template


    【解决方案1】:

    com.apple.dt.unit.prefixable 添加到祖先,它会自动添加对话框。然后,使用___VARIABLE_classPrefix:identifier___ 作为替换字符串。例如。假设您有一个名为 Foo 的类:

    @interface ___VARIABLE_classPrefix:identifier___Foo : NSObject
    @end
    
    @implementation ___VARIABLE_classPrefix:identifier___Foo
    @end
    

    文件不需要有那么长的前缀,你可以在你的定义中简单地做到这一点,方法是使用___VARIABLE_classPrefix:identifier___Foo.m 作为键,Foo.m 作为Path(或者不管你的命名如何)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-07
      • 1970-01-01
      • 2014-11-30
      • 1970-01-01
      • 1970-01-01
      • 2011-10-01
      • 1970-01-01
      • 2019-11-11
      相关资源
      最近更新 更多