如何在Xcode中保持标题注释更新 [英] How to keep the header comments up to date in Xcode

查看:195
本文介绍了如何在Xcode中保持标题注释更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Xcode有一种习惯,将各种(冗余)信息放在每个代码文件的顶部,包含版权声明,类名,项目名称和客户端名称。喜欢与否,一旦你创建一个新类A,然后重构它被称为B,信息已经错了。评论会一直说这是A.h或A.m。此外,如果您在下一个项目中重复使用类,它也会显示错误的项目名称。

  // 
// Ah
// ProjectName
//
//创建于19-06-11。
//版权所有2011 CompanyName。版权所有。
//

必须有一个理由没有很多人抱怨这个。你保持标题注释最新的是什么招?有没有自动纠正所有的工具?是否有隐藏设置?



干杯,
EP。

解决方案>

可能有一种更新您的评论的方法,但会很棘手。



自定义模板,这不是很糟糕。它只是一个文本文件位于
/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File Templates / Cocoa Touch /



不要在这里编辑文件,它们会在更新时被覆盖,或重新安装xcode。
将您的自定义模板放在您的主目录中。



〜/ Library / Developer / Xcode / Templates / File Templates / / code>



高阶位进一步解释


Xcode has a habit of putting all kinds of (redundant) information at the top of each code file it creates, containing copyright notices, class names, project names and client names. Like it or not, once you create a new class "A", then refactor it to be called "B", the information is wrong already. The comments will keep saying that this is "A.h" or "A.m". In addition, if you reuse classes from one project in a next, it will also state the wrong project name.

//
//  A.h
//  ProjectName
//
//  Created by Author on 19-06-11.
//  Copyright 2011 CompanyName. All rights reserved.
//

There must be a reason there aren't many people complaining about this. What is your trick to keep the header comments up to date? Is there a tool that auto-corrects it all? Is there a hidden setting?

Cheers, EP.

解决方案

There may be a way to update your comments but it will be tricky.

As far a customizing the template, this is not as bad. it is just a text file located in /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File Templates/Cocoa Touch/

Don't edit the files here, they will get overwritten when you update, or reinstall xcode. Place your custom templates here, in your home directory.

~/Library/Developer/Xcode/Templates/File Templates/

High Order Bit explains further.

这篇关于如何在Xcode中保持标题注释更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆