打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Swift和OC代码注释分析#pragmamark,FIXMEandTODO
转载:http://www.tuicool.com/articles/JVZjmm
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:
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
swift2.0 常用标注 //MARK
TableView的详细设置
TableVIew
15、iOS tableview的常用delegate和dataSource执行顺序
UITableViewDelegate UITableViewDataSource 执行顺序
如何在UINavigationBar上添加UISearchBar以及UISearchDisplayController的使用 OC iOS
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服