File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
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 ) .
You can’t perform that action at this time.
0 commit comments