Swift 3.0线程类目标不实现选择器

时间:2016-10-11 00:24:11

标签: swift multithreading macos oop macos-sierra

我为我的线程声明了一个属性:

let loggingThread = Thread.init(target: self, selector: Selector(("loggingThreadProcess:")), object: nil)

@objc func loggingThreadProcess(object: AnyObject?) {

}

但是我收到了这个错误:

  

[NSThread initWithTarget:selector:object:]:target未实现   selector(*** - [_ SwiftValue loggingThreadProcess:])

有什么建议吗?

1 个答案:

答案 0 :(得分:1)

您应该将其定义为:

let loggingThread = Thread.init(target: self, selector: #selector(loggingThreadProcess:), object: nil)