Using unresolved id 'println' in swift 3

I'm just new to Swift. I am trying to use very simple code, but I cannot print things with "println". This is my code

import Cocoa var myString:String? = nil if myString != nil { println(myString) }else { println("myString has nil value") } 
+7
swift
source share
1 answer

println() does not work in xcode. Instead, the print() function is used to print the statement using a new line.

If instead you need to print without a new line, terminator used

Try this for your code:

 import Cocoa var myString:String? = nil if myString != nil { print(myString) } else { print("myString has nil value") } 

Terminator example:

 import Cocoa var myString:String? = nil if myString != nil { print(myString, terminator:"") } else { print("myString has nil value", terminator:"") } 
+16
source share

All Articles