如何在 Xcode 标示「待办事项」 ?

目前我正在做一个基于 iOS 的图像处理任务。

问题:

我在研究不同的模块。因此,如果将来需要在模块中添加某些内容,我希望将其标记为“ To do note”。 在 Xcode 还有其他类似的宏吗?

我试过:

For this currently I'm using #pragma like:

#pragma mark -
#pragma mark To do: Add the Image processing methods.

我有:

但它在“方法”部分列出了如下内容:

To Do

我真正需要的是:

The issue is, it's listed under the methods list so sometimes I forgot to remove this from the section also it's very difficult to find it in entire source code. (Searching #pragma results to show entire lists)

技术详情:

I'm using Xcode Version 4.6.2 .

64749 次浏览
// TODO: the thing todo

就是你如何展示你的任务。

我知道了。

写下这样的评论:

// TODO: Do something

会成功的。

我得到了这样的东西:

TO DO


Also there is a lot of options like:

  1. // FIXME: Midhun < br/> < br/>
  2. // ???: Midhun < br/> < br/>
  3. // !!!: Midhun < br/> < br/>
  4. // MARK: Midhun

使用

//TODO: some thing here

如果您想要做的只是在下拉列表中查看待办事项列表,那么可以使用

如果你想打扰别人,你可以使用 #warning标记:

#warning this will create a compiler warning.

And when you build the app you will get a compiler warning (a yellow triangle, not a compiler error) which is a little more "in your face" about reminding you of things you need to do.

Another simple method, slightly outside the box, if you don't want to clutter up the methods listing bar, is to use a convention within comments like //Todo: and when you want to address them en-masse, simply select the Find Navigator, match case and search for //Todo:

我更喜欢这样,因为我不喜欢方法下拉菜单看起来像意大利面条代码。是的,我经常有很多 Todo:’s;)

通过下面的脚本,您可以看到所有必需的标记,如警告。

  1. 在“项目导航器”中选择项目
  2. 打开侧边栏中的目标并移动到“构建阶段”选项卡
  3. 点击“ +”标志
  4. 选择“新建运行脚本构建阶段” Script adding
  5. Add below script to "Run Script" Ready Script 剧本:

    KEYWORDS="TODO:|FIXME:|DevTeam:|XXX:"
    find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/ warning: \$1/"
    

enter image description here

Original answer was taken from Here

Another alternative is XToDo plugin for Xcode.

我倾向于这样写:

//TODO: Blah blah blah

然后我只需做一个 命令-转移-F并查找“//TODO”。

使用文件大纲下拉列表将只显示当前文件的 TODO,但我倾向于查看项目的 TODO 状态。

粗略的解决办法,但这是工作。

You can use XToDo plugin

Https://github.com/trawor/xtodo

use ctrl+t to trigger the List Window on/off

使用 ctrl + t 触发 List Window on/off

Toolbar exemple

Easy install with alcatraz 使用 ctrl + t 触发 List Window on/off

#error

and

#warning

也用于 C 语言编程

I started with

// TODO: Implement bubble sort.

然后我加入了一个大项目,有时候我需要一个待办事项来比一个在制品提交活得更长,所以为了区分我的待办事项和我的同事,我把我的待办事项和我的首字母放在一起:

// TODO: SM: Implement bubble sort

有时我想要更多的可见性,所以我开始在一些地方使用语用警告。

#warning Implement bubble sort

One day I decided to turn on hard mode by adding -Werror to my cflags. Unfortunately this makes pragma warnings useless because they prevent compilation. And so I went back to using // TODO: until Jeff Nadeau told me that I can put

-Wno-error=#warnings

这样就不会把语用警告看作是错误了。因此,现在 #warning-Werror可以并排生活。

我将已识别的标记分解成警告和错误,供自己使用,想在这里分享它:

KEYWORDS="STUB:|WARNING:|TODO:|FIXME:|DevTeam:|\?\?\?:"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -not -path "${SRCROOT}/Pods/*" -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/1: warning: \$1/"


KEYWORDS="ERROR:|XXX:|\!\!\!:"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -not -path "${SRCROOT}/Pods/*" -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/1: error: \$1/"
ERROR_OUTPUT=`find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -not -path "${SRCROOT}/Pods/*" -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/1: error: \$1/"`


exit ${#ERROR_OUTPUT}