Latest 0.6.1
Homepage https://github.com/dapperstout/swift-bytes
License MIT
Platforms ios 8.0, osx 10.9, tvos 9.0, requires ARC

Swift Bytes

Swift Version 4
Carthage compatible
CocoaPods Version Badge
License Badge
Supported Platforms Badge

This library contains a collection of helper methods for byte manipulation in Swift. It requires Swift 4.

If you’re like me, and can never remember whether you should double right-shift or tripple left-shift to get to the bits you want, then this library might be of some use to you.

Example

// Let's say we have an interesting 64 bit number:
let largeNumber: UInt64 = 0xF00FA00AB00BC00C

// Extracting the fifth byte, the hard way:
let fifthByte = UInt8((largeNumber >> 24) & 0xFF)

// Extracting the fifth byte using this libary:
let fifthByte = bytes(largeNumber)[4]

All available byte manipulation methods can be found in the Bytes.swift file. The BytesTests.swift file contains examples of their use.

Installation

You can use CocoaPods to add this library to your project. Use the following in your Podfile:

pod 'SwiftBytes'

After adding this library to your project, you can import it in your swift files:

import SwiftBytes

Latest podspec

{
    "name": "SwiftBytes",
    "version": "0.6.1",
    "summary": "Collection of helper methods for byte manipulation in Swift",
    "description": "This library contains a collection of helper methods fornbyte manipulation in Swift.nnIf you're like me, and can never remember whether you shouldndouble right-shift or tripple left-shift to get to thenbits you want, then this library might be of some use tonyou.",
    "homepage": "https://github.com/dapperstout/swift-bytes",
    "license": {
        "type": "MIT"
    },
    "authors": "Dapperstout",
    "source": {
        "git": "https://github.com/dapperstout/swift-bytes.git",
        "tag": "0.6.1"
    },
    "platforms": {
        "ios": "8.0",
        "osx": "10.9",
        "tvos": "9.0"
    },
    "swift_version": "4.0",
    "source_files": "SwiftBytes/SwiftBytes/**/*.swift",
    "requires_arc": true
}

Pin It on Pinterest

Share This