NSView的swift打印功能

时间:2018-06-17 15:40:40

标签: swift cocoa

我刚将项目移动到Xcode 10(实际上我将这些文件放在一个新创建的项目中)。

现在,在我的NSView子类中,Xcode告诉我:

public override func print(_ sender: Any?)

不会覆盖任何内容。 我想print()函数已被重命名,因为它确实与print()日志记录功能冲突。 我应该使用哪个名字?

1 个答案:

答案 0 :(得分:2)

从Swift 4 / Xcode 9开始,bool isTSinRange(uint64_t ts) { // how to make t1 t2 ts comparable and do the below if (t1<ts<t2) return true; else return false; } 方法

NSView

的形式导入Swift
- (void)print:(id)sender;

以便它不再与全局func printView(_ sender: Any?) 函数冲突。 此更改记录在AppKit Release Notes for macOS 10.13

  Swift中的

print()方法

     

NSWindow,NSView,NSDocument的print()实例方法已分别在Swift 4中重命名为printWindow(),printView()和printDocument()。这修复了将调试日志记录添加到其中一个子类的意外体验实例显示的是打印面板。

(在Swift论坛{@ 3}}的@hamishknight的帮助下找到。)