Created
December 24, 2018 05:36
-
-
Save AmatsuZero/ba71da374a678671dbf5835da91521f0 to your computer and use it in GitHub Desktop.
字符串转OSType
This file contains hidden or 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 String { | |
var fourCharCode: FourCharCode? { | |
guard self.count == 4 else { | |
return nil | |
} | |
return self.utf16.reduce(0) { $0 << 8 + FourCharCode($1) } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment