String
public extension String
-
Declaration
Swift
init(base58Encoding bytes: Data, alphabet: [UInt8] = Base58String.btcAlphabet) -
Returns a tuple breaking an EOSIO key formatted xxx_xx_xxxxxxx into components.
Declaration
Swift
func eosioComponents() throws -> (prefix: String, version: String, body: String) -
Returns the domain (host) component of a url.
Declaration
Swift
var urlDomain: String? { get } -
Slices the string starting from
fromand ending at the start of thetostring.Declaration
Swift
func slice(from: String, to: String) -> String?Parameters
fromThe begining of the slice.
toThe end of the slice.
Return Value
String?
-
Returns all the strings that match a regular expression.
Declaration
Swift
func matchingStrings(regex: String) -> [[String]]Parameters
regexThe string to use as a regular expression.
Return Value
An array of all the matched string or empty if no match were found.
-
Is the string an absolute URL?
Declaration
Swift
func isAbsoluteURL() -> BoolReturn Value
Returns
trueif the string is an absolute URL else returnsfalse. -
Converts the string to a dictionary if it is convertible to a dictionary (i.e., it is a JSON string.) and returns the dictionary. Otherwise, returns
nil.Declaration
Swift
var toJsonDictionary: [String : Any]? { get } -
Converts the string to a array if it is convertible to a array (i.e., it is a JSON string.) and returns the array. Otherwise, returns
nil.Declaration
Swift
var toJsonArray: [Any]? { get } -
Converts the string to a dictionary if it is convertible to a dictionary (i.e., it is a JSON string).
Throws
AEosioErrorif the string can not be converted to a dictionary.Declaration
Swift
func jsonToDictionary() throws -> [String : Any]Return Value
A dictionary if the text is a JSON string and convertible to a dictionary otherwise returns
nil. -
Converts an object to a JSON string if possible.
Declaration
Swift
static func jsonString(jsonObject: Any?, writingOptions: JSONSerialization.WritingOptions?) -> String?Parameters
jsonObjectAn object to convert to JSON string.
writingOptionsOptional array of WritingOptions to control the JSON string output.
Return Value
A string if the object is convertible to JSON string or nil.
-
Initializes a string from an object that conforms to
Encodableprotocol.Throws
EosioError if the passed object is not convertible to JSON string.Declaration
Swift
init<T>(encodeToJson: T) throws where T : EncodableParameters
encodeToJsonAn object that conforms to
Encodableprotocol. -
Declaration
Swift
var isValidBase58: Bool { get }Return Value
Bool indicating whether the current string is a validly encode base58 string.
-
Does the string contain all of the provided words?
Declaration
Swift
func contains(words: String) -> BoolParameters
wordsWords to look for in the string.
Return Value
trueif the string contains all of the words inwords. Otherwise, false. -
Declaration
Swift
var isValidEosioName: Bool { get }Return Value
trueif a string is a valid EOSIO name.
View on GitHub
String Extension Reference