Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working for me #15

Closed
jeremymoorecom opened this issue Mar 15, 2018 · 2 comments
Closed

Not working for me #15

jeremymoorecom opened this issue Mar 15, 2018 · 2 comments
Labels
invalid This doesn't seem right question Further information is requested

Comments

@jeremymoorecom
Copy link

jeremymoorecom commented Mar 15, 2018

Hello, perhaps I'm missing something.
I've created a new project and installed via CocoaPods.
Repeat is not firing:

    import UIKit
    import Repeat
    
    class ViewController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        print("view did load")
        // Do any additional setup after loading the view, typically from a nib.
        Repeater.once(after: .seconds(5)) { timer in
            print("tick")
        }
        let timer = Repeater(interval: .seconds(5), mode: .infinite) { _ in
            print("tock")
        }
        timer.start()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    }    

Thanks

@malcommac
Copy link
Owner

Hi, you need to keep timer live around, ie by setting it as variable in your view controller (otherwise it will get deallocated automatically).

import UIKit
import Repeat

class ViewController: UIViewController {

private var timer: Repeater?

override func viewDidLoad() {
    super.viewDidLoad()
    print("view did load")
    // Do any additional setup after loading the view, typically from a nib.
    self.timer = Repeater.once(after: .seconds(5)) { timer in
        print("tick")
    }
    let timer = Repeater(interval: .seconds(5), mode: .infinite) { _ in
        print("tock")
    }
    timer.start()
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

}

@malcommac malcommac added invalid This doesn't seem right question Further information is requested labels Mar 15, 2018
@jeremymoorecom
Copy link
Author

Good deal!!

Thanks for the update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants