SWIFT 2 prints (), how to hide?

Before Swift 2, you can hide all your println() with such a helper

func println( object: Any) {

#if DEBUG
Swift.println(object)
#endif

If you change to this

func print(object: Any) {

#if DEBUG
Swift.print(object)
#endif

It works as expected, but print() has a new appendLine function. So in your code you can write

println("Test", appendNewLine: false)< /pre> 

However, doing this means that the assistant mentioned above will no longer work. Any suggestions on how to solve this problem. Thank you very much.

For swift 2.2, this is what I use:

// Disable print for production.< br />func print(items: Any..., separator: String = "", terminator: String = "
") {
#if DEBUG
Swift.print(items[0], separator:separator, terminator: terminator)
#endif
}

Before Swift 2, you can hide all yours with such a helper println()

func println(object: Any) {

#if DEBUG
Swift.println(object)< br />#endif

If you change to this

func print(object: Any) {

#if DEBUG
Swift.print(object )
#endif

It works as expected, but print() has a new appendLine function. So in your code you can write

println("Test", appendNewLine: false)

However, doing so means that the assistant mentioned above will no longer work. Any suggestions on how to solve this problem. Thank you very much.< /p>

For swift 2.2, this is what I use:

// Disable print for production .
func print(items: Any..., separator: String = "", terminator: String = " ") {
#if DEBUG
Swift.print(items[0 ], separator:separator, terminator: terminator)
#endif
}

Leave a Comment

Your email address will not be published.