Swift   发布时间:2022-03-31  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Swift和OC代码注释分析 #pragma mark, FIXME and TODO大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

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... T

While coding in Objective-C,#pragma mark isveryhAndyfor code organization in the Jump Bar. Forexample:

#pragma mark – Initialization code here... 
#pragma mark – Table Management@H_186_20@more code here...
@H_262_29@ 

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 Management@H_186_20@more code here...
@H_262_29@ 

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()}
@H_262_29@ 

You can also add TODO: outside a method as shown below:

// TODO: revisit memory management handlingfunc setupMemoryRecoveryCode(){}
@H_262_29@ 

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}
@H_262_29@ 

The output in the Jump Bar looks as follows:

大佬总结

以上是大佬教程为你收集整理的Swift和OC代码注释分析 #pragma mark, FIXME and TODO全部内容,希望文章能够帮你解决Swift和OC代码注释分析 #pragma mark, FIXME and TODO所遇到的程序开发问题。

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

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。