I am trying to create a thread in swift and send two parameters. I create thread and this work:
let thread = NSThread(target:self, selector:"getData", object:nil)
thread.start()
But how to send parameters to my func getData? How to create object with parameters like this:
let params =...
let thread = NSThread(target:self, selector:"getData", object:params)
thread.start()
...
getData(username: String, password: String) {
...
}
NSThread
in Cocoa is almost always wrong. (On iOS, it's "always wrong" rather than "almost always wrong.") Apple has a very good document explaining how to convert thread-based constructions to Cocoa's concurrency model (called GCD). developer.apple.com/library/ios/documentation/General/… – Overhead