NSTimer with anonymous function / block?

iphone, nstimer, objective-c

Solution

You can actually call:

NSTimer.scheduledTimerWithTimeInterval(ti: NSTimeInterval,
                    target: AnyObject, 
                    selector: #Selector, 
                    userInfo: AnyObject?, 
                    repeats: Bool)

Use it like this:

NSTimer.scheduledTimerWithTimeInterval(1, 
                    target: NSBlockOperation(block: {...}), 
                    selector: #selector(NSOperation.main), 
                    userInfo: nil, 
                    repeats: true)

Problem

I want to be able to schedule three small events in the future without having to write a function for each. How can I do this using `NSTimer`? I understand blocks facilitate anonymous functions but can they be used within `NSTimer` and if so, how? ``` [NSTimer scheduledTimerWithTimeInterval:gameInterval target:self selector:@selector(/* I simply want to update a label here */) userInfo:nil repeats:NO]; ```

Original source