Latest 4.3.1
Homepage https://github.com/FitnessKit/DataDecoder
License MIT
Platforms ios 8.0, osx 10.10, tvos 9.0, watchos 2.0
Authors

Swift Data Decoder. Easily Decode Data values

Swift4
CI Status
Version
License
Platform
Readme Score

Installation

DataDecoder is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "DataDecoder"

Swift Package Manager:

Swift3

    dependencies: [
        .Package(url: "https://github.com/FitnessKit/DataDecoder", majorVersion: 0)
    ]

Swift4

    dependencies: [
        .package(url: "https://github.com/FitnessKit/DataDecoder", from: "4.3.1"),
    ]

How to Use

Example:

let sensorData: Data = Data([ 0x02, 0xFE, 0xFF, 0xEF, 0xBE, 0xAD, 0xDE, 0xA5])

var decoder = DecodeData()
let height = decoder.decodeUInt8(sensorData)
let weight = decoder.decodeUInt16(sensorData)
let deadbeef = decoder.decodeUInt32(sensorData)
let nib = decoder.decodeNibble(sensorData)
//This should come back 0 as there is no more data left
let novalue = decoder.decodeNibble(sensorData)

Example Using Optionals:

let sensorData: Data = Data([ 0x02, 0xFE, 0xFF, 0xEF, 0xBE, 0xAD, 0xDE, 0xA5])

var decoder = DecodeData()

if let height = decoder.decodeUInt8IfPresent(sensorData) {}
let weight = decoder.decodeUInt16IfPresent(sensorData)
let deadbeef = decoder.decodeUInt32IfPresent(sensorData)
let nib = decoder.decodeNibbleIfPresent(sensorData)
// This will be nil as there is no data left
let novalue = decoder.decodeUInt8IfPresent(sensorData)

Data Decoders

  • Nibble
  • UInt8/Int8
  • UInt16/Int16
  • UInt24/Int23
  • UInt32/Int32
  • UInt48
  • UInt64/Int64
  • IP Address to String Value
  • MAC Address to String Value

IEEE-11073

  • 16-bit SFLOAT
  • 32-bit FLOAT

IEEE-754

  • Float32
  • Float64

Author

This package is developed and maintained by Kevin A. Hoogheem

License

DataDecoder is available under the MIT license

Latest podspec

{
    "name": "DataDecoder",
    "version": "4.3.1",
    "summary": "Swift Data Decoder. Easily Decode Data values",
    "description": "Swift Data Decoder. Easily Decode Data values.",
    "homepage": "https://github.com/FitnessKit/DataDecoder",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Kevin A. Hoogheem": "[email protected]"
    },
    "source": {
        "git": "https://github.com/FitnessKit/DataDecoder.git",
        "tag": "4.3.1"
    },
    "platforms": {
        "ios": "8.0",
        "osx": "10.10",
        "tvos": "9.0",
        "watchos": "2.0"
    },
    "source_files": "Sources/**/*"
}

Pin It on Pinterest

Share This