LoginSignup
21
21

More than 5 years have passed since last update.

[Swift]Logの出し方色々

Last updated at Posted at 2014-07-28

Objective-Cでログを出すときはNSLogを使っていました。
Swiftでは色々と書き方があるようなので紹介します。

コード

var i:Int = 1

//case1
NSLog("%d", i)

//case2
NSLog("\(i)")

//case3
println(i)

出力結果

2014-07-28 17:42:33.823 Log[2537:61925] 1
2014-07-28 17:42:33.825 Log[2537:61925] 1
1

まとめ

公式の文書を見るとNSLogは使用せず、println()を使う書き方をしているのでそれが推奨なのかもしれません。

21
21
3

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
21
21