Created
November 16, 2016 13:52
-
-
Save louisdh/df02466a9d39fc8db83b9c8c25503d59 to your computer and use it in GitHub Desktop.
Swift Data extension for easily converting to String
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
import Foundation | |
extension Data { | |
var utf8String: String? { | |
return string(as: .utf8) | |
} | |
func string(as encoding: String.Encoding) -> String? { | |
return String(data: self, encoding: encoding) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment