Skip to content

Commit 09ba2a5

Browse files
committed
Create README.md
1 parent c05699e commit 09ba2a5

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<img src="https://raw.githubusercontent.com/Cosmo/BinaryKit/master/BinaryKitLogo.png" alt=" text" width="100" />
2+
3+
# BinaryKit
4+
Access bits and bytes directly in Swift.
5+
6+
## Usage
7+
8+
Initialize from `NSData`
9+
```swift
10+
let data = NSData(...)
11+
let binary = Binary(data: data)
12+
```
13+
14+
or `[UInt8]` bytes array
15+
```swift
16+
let binary = Binary(bytes: [0xDE, 0xAD]) // 1101 1110 1010 1101
17+
```
18+
19+
```swift
20+
// Bits
21+
binary.bit(0) as Int // 1
22+
binary.bit(1) as Int // 1
23+
binary.bit(2) as Bit // .Zero
24+
binary.bit(3) as Bit // .One
25+
binary.bits(0, 16) // 57005
26+
27+
// Bytes
28+
binary.byte(0) as Int // 222
29+
binary.byte(0, 2) as Int // 57005
30+
```
31+
32+
## Todos
33+
34+
- [ ] Endianness flag
35+
- [ ] Tests
36+
- [ ] Documentation
37+
38+
## License
39+
40+
BinaryKit is released under the [MIT License](http://www.opensource.org/licenses/MIT).

0 commit comments

Comments
 (0)