Created
December 24, 2019 05:15
-
-
Save monsoir/d981d3d3cd77364b4722746487f33b92 to your computer and use it in GitHub Desktop.
Bool Extensions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Bool { | |
/// 转换为 16 进制数据 | |
var bytes: [UInt8] { | |
return self ? [UInt8(1)] : [UInt8(0)] | |
} | |
var binaryData: Data { | |
return Data(bytes) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment