CocoaDaemon
Daemon Kit to manage background closures to be called each set period of time
- Three properties, name, time and status to each closures.
- Option to update any of the properties.
- Shared object implementation.
- Option to instantiate a custom object instead of used the shared object.
-
Make sure
use_frameworks!
is added to yourPodfile
. -
Include the following in your
Podfile
:
pod 'CocoaDaemon'
- Run
pod install
Work with this Daemon is easy, most of the time the only thing you should be worry about will be to submit your closures and remove them as well.
Your closure must receive one parameter, this parameter will be a block that should be called if you want your closure to be scheduled for another call.
If you submit your block as inactive (active equal to false), it wouldn't be called and his status will be checked again on an on until the status change to active and in this time it will be called.
Daemon.sharedInstance.submitBlock("YourBlockName",
block: { (completion: @escaping () -> Void) in
// Do your work here.
// Call completion if you want your block be scheduled again.
completion()
},
active: true, seconds: 0.2)