Swift和OC代码注释分析 #pragma mark, FIXME and TODO
来源:互联网 发布:mac抹掉进程失败 编辑:程序博客网 时间:2024/05/21 09:31
While coding in Objective-C, #pragma mark isveryhandyfor code organization in the Jump Bar. Forexample:
#pragma mark – Initialization code here... #pragma mark – Table Managementmore code here...
The Jump Bar would show the following, where code sections areclearly marked:
#pragma mark Alternative for Swift
Xcode 6 now supports a similar featureusing // MARK:
// MARK: - Initializationcode here... // MARK: - View Managementmore code here...
With the result being:
The “-” after //MARK: is optional, including the “-”results the divider line shown just above thetext.
// TODO: in Swift
Although not used as frequently (at least from my perspective),but handy none-the-less are FIXME and TODO. The later is nice whenyou need to set a reminder for code that you need to revisit.
override func viewDidLoad(){ super.viewDidLoad() // TODO: add configuration code self.configureView()}
You can also add TODO: outside a method as shown below:
// TODO: revisit memory management handlingfunc setupMemoryRecoveryCode(){}
Notice in the screenshot below that the TODO: references appearat different levels – the first TODO: isindented, indicating it is referencing something to do inside themethod itself.
// FIXME: in Swift
// FIXME: works in a similar manner, as it can be place eitherinside or out of a method.
For example, I’ll often place a // FIXME: with a bug referenceonce I track down the location of the problem. This gives me amarker and I can quickly return to the issue later.
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{ // FIXME: - Bug 2102 let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell let object = objects[indexPath.row] as NSDate cell.textLabel.text = object.description return cell}
The output in the Jump Bar looks as follows:
- Swift和OC代码注释分析 #pragma mark, FIXME and TODO
- Swift和OC代码注释分析 #pragma mark, FIXME and TODO
- Swift’s Answer to #pragma mark, FIXME and TODO
- iOS 标注#pragma mark、FIXME、TODO等等
- 代码注释TODO FIXME XXX
- 代码中的特殊注释技术--TODO、FIXME和XXX
- 代码注释中TODO、FIXME和XXX的含义
- 关于oc的#pragma mark - 和swift的注释的详解和区别
- Java代码注释XXX todo fixme
- 代码中的注释FIXME/TODO/XXX
- 代码中的特殊注释-TODO,FIXME,XXX
- 代码中的特殊注释:ToDo、FIXME、XXX
- 【注释】代码中特殊的注释技术——TODO、FIXME和XXX
- Xcode MARK TODO FIXME 标记
- Xcode TODO MARK FIXME 标记
- 代码中特殊的注释技术——TODO、FIXME和XXX的用处
- 代码中特殊的注释技术——TODO、FIXME和XXX的用处
- 代码中特殊的注释技术——TODO、FIXME和XXX的用处
- Android UI SurfaceView的使用-绘制组合图型,并使其移动
- Oracle存储过程实例
- Ubuntu 14.04鼠标光标狂闪问题
- 第4周 项目3 - 单链表应用(1)
- 第三周项目4--顺序表应用(1)
- Swift和OC代码注释分析 #pragma mark, FIXME and TODO
- 第四周【数据结构实践项目——链表 项目5 - 猴子选大王】
- 阅读《时间,管理把握最宝贵的财富》摘录(1)
- 软件测试知识点
- java基础---类中的名称
- 【第4周 项目5 - 猴子选大王】
- 实现android gif图片动画播放功能
- 快速选择
- xXx时间屏保