Author: Chris Lattner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class MyClass { | |
func startTimer() { | |
NSTimer.scheduledTimerWithTimeInterval(2, target: self, selector: #selector(MyClass.onTimer(_:)), userInfo: nil, repeats: false) | |
} | |
@objc func onTimer(timer:NSTimer!) { | |
print("Timer here") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIViewController { | |
func isVisible() -> Bool { | |
return self.isViewLoaded() && self.view.window != nil | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Description: | |
Given the triangle of consecutive odd numbers: | |
1 | |
3 5 | |
7 9 11 | |
13 15 17 19 | |
21 23 25 27 29 | |
... |