Swift和OC代码注释分析 #pragma mark, FIXME and TODO

Swift和OC代码注释分析 #pragma mark, FIXME and TODO,第1张

概述转载:http://www.tuicool.com/articles/JVZjmm While coding in Objective-C, #pragma mark isvery handyfor code organization in the Jump Bar. For example:  #pragma mark – Initialization code here... #pragma

转载:http://www.tuicool.com/articles/JVZjmm

While Coding in Objective-C,#pragma mark isvery handyfor code organization in the Jump bar. For example:

#pragma mark – Initialization code here... #pragma mark – table Managementmore code here...

The Jump bar would show the following,where code sections are clearly marked:

#pragma mark Alternative for Swift

Xcode 6 Now supports a similar feature using// 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 the text.

// 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 when you 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 appear at different levels – the first Todo: is indented,indicating it is referencing something to do insIDe the method itself.

// FIXME: in Swift

// FIXME: works in a similar manner,as it can be place either inside or out of a method.

For example,I’ll often place a // FIXME: with a bug reference once I track down the location of the problem. This gives me a marker 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所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1077760.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存