In the working version, I think the timer is first set to nil and then changed 
to the scheduled timer.  In the non-working case time can only be set exactly 
once and self access is not legal until after it is set.

Ray


> On Feb 1, 2017, at 8:06 PM, Brandon Knope via swift-users 
> <swift-users@swift.org> wrote:
> 
> class Test {
>     let timer: Timer!
>     
>     init() {
>         timer = Timer.scheduledTimer(timeInterval: 20, target: self, 
> selector: #selector(test(_:)), userInfo: nil, repeats: true)
>     }
>     
>     @objc func test(_ timer: Timer) {
>         
>     }
> }

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to