println was changed to print

Hi all,

unfortunately Apple changed println() to print() which gives me some issues.

I have a NSImageView subclass where I catch which NSImageView is currently in use.

To see which NSImageView was entered or clicked I use a couple of mouse events (see at bottom of page) and print(theEvent) to see the result in the debugger.

Instead of printing a line in the debugger I´m faced with a printing dialog. Pretty strange.



When I´m using print() in an other context, where no graphical elements are involved things work as exspected.


print("\(__FILE__.lastPathComponent)[\(__LINE__)] \(__FUNCTION__)")

⇒ ViewController.swift[221] saveAndCloseSettings


Anyone got similar behavior? What am I doing wrong?


Greetings from Switzerland, Ronald Hofmann

---


//Catching mouse events in my subclass

override func mouseEntered(theEvent: NSEvent) {

print(theEvent)

}


override func mouseDown(theEvent: NSEvent) {

print(theEvent)

}


override func mouseDragged(theEvent: NSEvent) {

print(theEvent)

}


override func mouseMoved(theEvent: NSEvent) {

print(theEvent)

}

SAME HAPPENED WITH ME! this really stinks. I even tried to use the print(value, appendNewline) but it ended up trying to identify the functinon as the ImageView print() function and said that the appendNewLine part should not exist. I say GO BACK TO println()! Two letters will not make a difference and things are more clear this way.

Use Swift.print() .

It's documented in the Xcode 7 Release Notes.


Known Issues in Xcode 7 beta 4 — Swift 2.0 and Objective-C

Swift Language & Compiler

• In OS X Cocoa apps, subclasses of NSView have a “print” method that shadows the global Swift “print” function. Referring to “print” inside an NSView subclass invokes this method and bring up a Print panel instead of printing to the console.

Workaround: Qualify references to “Swift.print” to use the global function. (18309853)




You can define your own global function println.

func println<T>(x: T) {Swift.print(x)}
func printc<T>(x: T) {Swift.print(x, appendNewLine: false)}

(Actually, in global context, you have no need to prefix `Swift.`.)

println was changed to print
 
 
Q