Swiftで開発をする上で(備忘録)


開発においての一つの方法

・Storyboardは画面遷移を定義するためだけに使う

・各コントローラーのUI構成は、xibで作る

・画面の遷移処理はperformSegueWithIDでやる

・delegate callback notificationの使い分け

リリース時でのログの排除

デバック時のみログを出力し、リリース時にはログを出さないようにするには、

// リリースビルドでprint, debugPrintを無効化

func print(object: Any) {
    #if DEBUG
        Swift.print(object, terminator: "")
    #endif
}

func debugPrint(object: Any) {
    #if DEBUG
        Swift.debugPrint(object, terminator: "")
    #endif
}

// リリースビルドでNSLog無効化
func NSLog(message:String){
    #if DEBUG
        Foundation.NSLog(message)
    #endif
}
func NSLog(format:String, _ args:CVarArgType...){
    #if DEBUG
        Foundation.NSLog(String(format: format, arguments: args))
    #endif
}