Data
public extension Data
-
Get HEX string from data. Can be used for sending APNS token to backend.
Declaration
Swift
var hexString: String { get }
-
Creates data from HEX string
Declaration
Swift
init(hex: String)
-
Try to convert data to ASCII string
Declaration
Swift
var asciiString: String? { get }
-
Try to convert data to UTF8 string
Declaration
Swift
var utf8String: String? { get }
-
String representation for data. Try to decode as UTF8 string at first. Try to decode as ASCII string at second. Uses hex representation if data can not be represented as UTF8 or ASCII string.
Declaration
Swift
var asString: String { get }
-
Try to serialize JSON data
Declaration
Swift
var jsonObject: Any? { get }
-
Try to get dictionary from JSON data
Declaration
Swift
var jsonDictionary: [String : Any]? { get }
-
Try to get array from JSON data
Declaration
Swift
var jsonArray: [Any]? { get }
-
Try to get string for key in dictionary from JSON data
Declaration
Swift
func jsonDictionaryStringForKey(_ key: String) -> String?
-
Initialize data with content of a given file and report error if unable.
Declaration
Swift
init?(safeContentsOf url: URL, file: String = #file, function: String = #function, line: UInt = #line)
-
Write the contents of the
Data
to a location and report error if unable.Throws
An error in the Cocoa domain, if there is an error writing to theURL
.Declaration
Swift
@discardableResult func safeWrite(to url: URL, options: Data.WritingOptions = [], file: String = #file, function: String = #function, line: UInt = #line) -> Bool
Parameters
url
The location to write the data into.
options
Options for writing the data. Default value is
[]
.