Latest 1.0.0
Homepage https://github.com/lucianomarisi/Runner
License MIT The MIT License (MIT)

Copyright (c) 2016 Luciano Marisi

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Platforms ios 8.0
Authors

Build Status

codecov.io

Easily execute a block at specific time intervals.

Installation

Either

OR

  • Add the files inside the Runner folder to your project

Examples

Execute a predefined set of points

// Generate some points
var mockPoints = [Point]()
let numberOfPoints = 10
let totalTime = 1.0
for index in 0...numberOfPoints {
  let timestamp = NSTimeInterval(index) * totalTime / Double(numberOfPoints)
  let mockPoint = Point(timestamp: timestamp, value: Double(index))
  mockPoints.append(mockPoint)
}

// Execute blocks at the times from the mocked points
let runner = Runner()
runner.startWithMockPoints(mockPoints) { (point) -> Void in
  NSLog("(point.value)")
}

This will produce the following logs:

Execute points using a function


// Define function to generate points
func sineSignal(nextTimestamp: NSTimeInterval) -> Point {
  let signalFrequency = 1.0
  let amplitude = 2.0
  let offset = 0.5
  let phaseShift = 0.2
  let value = amplitude * sin(nextTimestamp * signalFrequency + phaseShift) + offset
  return Point(timestamp: nextTimestamp, value: value)
}

let runner = Runner()
// Start executing points
runner.startWithFunction(sineSignal) { (point) -> Void in
  NSLog("(point.value)")
}

// Stop executing points
runner.stop()

This will produce the following logs:

Latest podspec

{
    "name": "Runner",
    "version": "1.0.0",
    "license": {
        "type": "MIT",
        "text": "    The MIT License (MIT)nn    Copyright (c) 2016 Luciano Marisinn    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:nn    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.nn    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.n"
    },
    "homepage": "https://github.com/lucianomarisi/Runner",
    "authors": {
        "Luciano Marisi": "[email protected]"
    },
    "summary": "Execute a block at specific time intervals",
    "source": {
        "git": "https://github.com/lucianomarisi/Runner.git",
        "tag": "1.0.0"
    },
    "source_files": "Runner/**/*.swift",
    "platforms": {
        "ios": "8.0"
    }
}

Pin It on Pinterest

Share This