Skip to content

Instantly share code, notes, and snippets.

@louisdh
Created November 16, 2016 13:52
Show Gist options
  • Save louisdh/df02466a9d39fc8db83b9c8c25503d59 to your computer and use it in GitHub Desktop.
Save louisdh/df02466a9d39fc8db83b9c8c25503d59 to your computer and use it in GitHub Desktop.
Swift Data extension for easily converting to String
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