import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@objc class myClass:NSObject {
func myFunc(){
for var i = 0; i < 10000; i++ {
print(i,[NSThread.currentThread()]);
}
}
}
var myObj = myClass()
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
_ = NSThread.init(target: myObj, selector:Selector(myObj.myFunc()),
object: nil)
}
}
when I run the code above, Xcode has a exception.the information is
[NSThread initWithTarget:selector:object:]: target does not implement selector
how to use performSelectorInBackground in swift ??