Skip to content

Commit

Permalink
Create README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Cosmo committed Jan 7, 2016
1 parent c05699e commit 09ba2a5
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<img src="https://raw.githubusercontent.com/Cosmo/BinaryKit/master/BinaryKitLogo.png" alt=" text" width="100" />

# BinaryKit
Access bits and bytes directly in Swift.

## Usage

Initialize from `NSData`
```swift
let data = NSData(...)
let binary = Binary(data: data)
```

or `[UInt8]` bytes array
```swift
let binary = Binary(bytes: [0xDE, 0xAD]) // 1101 1110 1010 1101
```

```swift
// Bits
binary.bit(0) as Int // 1
binary.bit(1) as Int // 1
binary.bit(2) as Bit // .Zero
binary.bit(3) as Bit // .One
binary.bits(0, 16) // 57005

// Bytes
binary.byte(0) as Int // 222
binary.byte(0, 2) as Int // 57005
```

## Todos

- [ ] Endianness flag
- [ ] Tests
- [ ] Documentation

## License

BinaryKit is released under the [MIT License](http://www.opensource.org/licenses/MIT).

0 comments on commit 09ba2a5

Please sign in to comment.