LoginSignup
134
127

More than 5 years have passed since last update.

Swiftのドキュメントコメント

Last updated at Posted at 2015-09-22

追記: Xcode 8なら、 簡単にコメントのひな形を挿入できますよ。


Swiftのドキュメントコメントの書き方がXcode 7から(Swift 2から?)変わっているようなのでメモ

Xcode 7での書き方

  • Markdown形式
  • パラメーターは - parameter <パラメーター名>: <説明>
  • 戻り値は - returns: <説明>
/// なんか **うまいこと** やるよ。
/// - parameter foo: 1つ目の引数。
/// - parameter bar: 2つ目の引数。
/// - returns: うまいことやったらtrueを返すよ。
func doSomething(foo: String, bar:Int) -> Bool {
    // do nothing :P
    return false
}

メソッド名の上でOption-クリックで確認

xcode7.png

参考にしたもの

Xcode 6での書き方

  • reStructuredText形式
  • パラメーターは :param: <パラメーター名> <説明>
  • 戻り値は :returns: <説明>
/// なんか **うまいこと** やるよ。
///
/// :param: foo 1つ目の引数。
/// :param: bar 2つ目の引数。
/// :returns: うまいことやったらtrueを返すよ。
func doSomething(foo: String, bar:Int) -> Bool {
    // do nothing :P
    return false
}

メソッド名の上でOption-クリックで確認

xcode6.png

参考にしたもの
134
127
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
134
127