CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.
TestsTested | ✓ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Feb 2015 |
Maintained by Rich Robinson.
A simple facility for running scheduled, repeating tasks within an iOS app using cron-like strings for minutes.
Note that scheduled tasks only execute while your app is running in the foreground.
RCRScheduledTask
has been verified as working with Xcode 6.1 and iOS 8.1.
Additionally, RCRScheduledTask
depends on RCRTimers
. If installing via CocoaPods you will get RCRTimers
automatically.
All code uses ARC.
Firstly, if you are not installing via CocoaPods you will need to obtain RCRTimers
and add it to your project. If you are using CocoaPods this dependency will be satisfied automatically and there is nothing you need to do here.
Next, add the RCRScheduledTask
folder and code to your project.
Then, one way to quickly setup a scheduled task from a view controller would be as follows.
Import RCRScheduledTask.h
into your view controller:
#import "RCRScheduledTask.h"
Next, add a property for a scheduled task:
@property (nonatomic, strong) RCRScheduledTask *scheduledTask;
Then, in your viewDidLoad
method, initialize the scheduled task, passing it a schedule string, and a block of code to call according to the schedule. For example:
self.scheduledTask = [RCRScheduledTask scheduledTaskWithScheduleString:@"*" block:^{
NSLog(@"I’m a scheduled task! I run every minute");
}];
In this case we’re using a schedule string of *
(which means ‘run every minute’) and we’re simply logging a message using NSLog()
.
Some additional examples of schedule strings are listed below:
*/5
0,5,10,15
5
(Where 0, 5, 10 and 15 are arbitrary minute numbers.)
Further examples of schedule strings and full documentation comments can be found in the sample project.
A sample project containing several examples of scheduled tasks, along with unit tests for RCRScheduledTask
, can be found in the RCRScheduledTaskSample
folder.
The latest API documentation can be found on CocoaDocs.
MIT License (see LICENSE
in the root of the repository).