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
from
and ending at the start of theto
string.Declaration
Swift
func slice(from: String, to: String) -> String?
Parameters
from
The begining of the slice.
to
The end of the slice.
Return Value
String?
-
Returns all the strings that match a regular expression.
Declaration
Swift
func matchingStrings(regex: String) -> [[String]]
Parameters
regex
The 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() -> Bool
Return Value
Returns
true
if 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
AEosioError
if 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
jsonObject
An object to convert to JSON string.
writingOptions
Optional 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
Encodable
protocol.Throws
EosioError if the passed object is not convertible to JSON string.Declaration
Swift
init<T>(encodeToJson: T) throws where T : Encodable
Parameters
encodeToJson
An object that conforms to
Encodable
protocol. -
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) -> Bool
Parameters
words
Words to look for in the string.
Return Value
true
if the string contains all of the words inwords
. Otherwise, false. -
Declaration
Swift
var isValidEosioName: Bool { get }
Return Value
true
if a string is a valid EOSIO name.