Swift 2 学习笔记 15.文档注释

课程来自慕课网liuyubobobo老师


文档注释
  • 注释基础和Mark Down
/**
 Role:游戏角色
 
 被子类User继承

 + name:角色名
 + group:组织名
*/
class Role {
    var name: String
    var group: String
    
    init(name: String, group: String) {
        self.name = name
        self.group = group
    }
}

/// inherit from Role
class User: Role {
}
  • Parameters,Returns,Throws
/**
 The sum of two numbers:
 
 - Parameters:
   - num1: the first number
   - num2: the sceond number
 - Returns: The sum of num1 and num2
 - Throws: num1 or num2 is nil
*/

func sum(num1: Int,num2: Int) -> Int {
    return num1 + num2
}
  • 更多文档注释关键字
/// - Precondition: The object must contain all the information in the world.
/// - Postcondition: After the algorithm, the object will contain all the information in the universe.
/// - Requires: All the information in the object should be sorted.
/// - Invariant: The object will maintain sorted.
/// - Complexity: O(n^n)
/// - Important: Please only call this algorithm once in your program.
/// - Warning: Very computation consuming.
/// - Attention: Same as Warning.
/// - Note: I terribly doubt this algorihtm.
/// - Remark: Same as Note.

/// - Author: liuyubobobo
/// - Authors: All the geeks in the world:)
/// - Copyright: liuyubobobo@2016
/// - Date: 26 Jan, 2016
/// - Since: iOS 5
/// - Version: 3.1415926
  • MARK, TODO和FIXME
// TODO: Offer a all parameters initializer
// MARK: Methods
// FIXME: Support Swift 2.2
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容