Swift’s Answer to #pragma mark, FIXME and TODO
2015-05-27 21:17
344 查看
转载:http://www.th7.cn/Program/c/201408/271216.shtml
While coding in Objective-C, #pragma mark isvery handyfor code organization in the Jump Bar. For example:
The Jump Bar would show the following, where code sections are clearly marked:
With the result being:
The “-” after // MARK: is optional, including the “-” results the divider line shown just above the text.
You can also add TODO: outside a method as shown below:
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.
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.
The output in the Jump Bar looks as follows:
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... |
#pragma mark Alternative for Swift
Xcode 6 now supports a similar feature using // MARK:// MARK: - Initializationcode here... // MARK: - View Managementmore code here... |
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 codeself.configureView()} |
// TODO: revisit memory management handlingfunc setupMemoryRecoveryCode(){} |
// 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 2102let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCelllet object = objects[indexPath.row] as NSDatecell.textLabel.text = object.descriptionreturn cell} |
相关文章推荐
- Swift和OC代码注释分析 #pragma mark, FIXME and TODO
- Swift和OC代码注释分析 #pragma mark, FIXME and TODO
- Xcode MARK TODO FIXME 标记
- Xcode TODO MARK FIXME 标记
- Qt TODO/FIXME 功能
- 从Objective-C到Swift,你必须会的(一)#pragma mark
- Welcome-to-Swift-09类和结构体(Classes and Structures)
- When to use LinkedList and When to use ArrayList- An answer in StackOverFlow
- PH FIN want to have PR/PO in TWD and SGD but do invoice matching and payment in USD
- Something about doing and to do
- 从Objective-C到Swift,你必须会的(一)#pragma mark
- How to collect stats of apps from CloudFoundry and do analysis?
- Xcode and #pragma mark
- What does appending “?v=1” to CSS and Javascript URLs in link and script tags do?
- Swift中推送通知设置:Binary operator '|' cannot be applied to two UIUserNotificationType operands 错误解决
- Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false 错误
- CRUD for user and other things to do...
- the answer to life, the universe and everything
- How to make awesome UI components in iOS 8 using Swift and XCode 6
- 代码中的TODO FIXME XXX 等注释释义