Declared in NSTimer+BMKitAdditions.h

Overview

BMKit related additions to the NSTimer class.

Tasks

Creating a Timer

Class Methods

scheduledTimerWithTimeInterval:block:userInfo:repeats:

Creates and returns a new NSTimer object and schedules it on the current run loop in the default mode.

+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)seconds block:(BMTimerBlock)aBlock userInfo:(id)userInfo repeats:(BOOL)repeats

Parameters

seconds

The number of seconds between firings of the timer. If seconds is less than or equal to 0.0, this method chooses the non-negative value of 0.1 milliseconds instead.

aBlock

The block to invoke when the timer fires. The block is copied by the timer and released when the timer is invalidated.

userInfo

The user info for the timer. The object you specify is retained by the timer and released when the timer is invalidated. This parameter may be nil.

repeats

If YES, the timer will repeatedly reschedule itself until invalidated. If NO, the timer will be invalidated after it fires.

Return Value

A new NSTimer object, configured according to the specified parameters.

Discussion

After seconds have elapsed, the timer fires, invoking the block aBlock passing the timer as parameter.

Declared In

NSTimer+BMKitAdditions.h

timerWithTimeInterval:block:userInfo:repeats:

Creates and returns a new NSTimer object initialized with the specified block.

+ (NSTimer *)timerWithTimeInterval:(NSTimeInterval)seconds block:(BMTimerBlock)aBlock userInfo:(id)userInfo repeats:(BOOL)repeats

Parameters

seconds

The number of seconds between firings of the timer. If seconds is less than or equal to 0.0, this method chooses the non-negative value of 0.1 milliseconds instead.

aBlock

The block to invoke when the timer fires. The block is copied by the timer and released when the timer is invalidated.

userInfo

The user info for the timer. The object you specify is retained by the timer and released when the timer is invalidated. This parameter may be nil.

repeats

If YES, the timer will repeatedly reschedule itself until invalidated. If NO, the timer will be invalidated after it fires.

Return Value

A new NSTimer object, configured according to the specified parameters.

Discussion

You must add the new timer to a run loop, using addTimer:forMode:. Then, after seconds seconds have elapsed, the timer fires, invoking the block aBlock passing the timer as parameter. If the timer is configured to repeat, there is no need to subsequently re-add the timer to the run loop.

Declared In

NSTimer+BMKitAdditions.h

Instance Methods

initWithFireDate:interval:block:userInfo:repeats:

Initializes a new NSTimer object using the specified block.

- (id)initWithFireDate:(NSDate *)date interval:(NSTimeInterval)seconds block:(BMTimerBlock)aBlock userInfo:(id)userInfo repeats:(BOOL)repeats

Parameters

date

The time at which the timer should first fire.

seconds

For a repeating timer, this parameter contains the number of seconds between firings of the timer. If seconds is less than or equal to 0.0, this method chooses the nonnegative value of 0.1 milliseconds instead.

aBlock

The block to invoke when the timer fires. The block is copied by the timer and released when the timer is invalidated.

userInfo

Custom user info for the timer. The object you specify is retained by the timer and released when the timer is invalidated. This parameter may be nil.

repeats

If YES, the timer will repeatedly reschedule itself until invalidated. If NO, the timer will be invalidated after it fires.

Return Value

The receiver, initialized such that, when added to a run loop, it will fire at date and then, if repeats is YES, every seconds after that.

Discussion

You must add the new timer to a run loop, using addTimer:forMode:. Upon firing, the timer invokes the block aBlock passing the timer as parameter. If the timer is configured to repeat, there is no need to subsequently re-add the timer to the run loop.

Declared In

NSTimer+BMKitAdditions.h