It’s a Cocoa thing: Print and NSView #swiftlang

Once again the question popped up on why is “print” sending jobs to the printer when run on Cocoa? The answer is that print is an instance method on NSView, which queues print jobs.

If the compiler flags your use of print with a warning, specifically “Use of ‘print’ treated as a reference to instance method in class ‘NSView'”, change your code to use Swift.print (not this). This will avoid starting a print job.

One Comment

  • Thanks! Helpful!