Saturday, October 25, 2014

NSThread.detachNewThreadSelector

    override func viewDidLoad() {
        super.viewDidLoad()
        
        NSThread.detachNewThreadSelector(Selector("mythread"), toTarget: self, withObject: nil)
        
        println("End viewDidLoad()")
    }

    func mythread() {
        NSThread.sleepForTimeInterval(1.0)
        for var i = 1 ; i <= 5 ; i++ {
            println("\(i)")
        }
    }

==========================
Output:

End viewDidLoad()
1
2
3
4
5

No comments:

Post a Comment