ReadOnlyDictionaryObject

public class ReadOnlyDictionaryObject: ReadOnlyDictionaryProtocol

ReadOnlyDictionaryObject provides readonly access to dictionary data.

  • The number of entries in the dictionary.

    Declaration

    Swift

    public var count: Int
  • An array containing all keys, or an empty array if the dictionary has no entries.

    Declaration

    Swift

    public var keys: Array<String>
  • Gets a property’s value. The value types are Blob, ReadOnlyArrayObject, ReadOnlyDictionaryObject, Number, or String based on the underlying data type; or nil if the value is nil or the property doesn’t exist.

    Declaration

    Swift

    public func value(forKey key: String) -> Any?

    Parameters

    key

    the key.

    Return Value

    the object value or nil.

  • Gets a property’s value as a string. Returns nil if the property doesn’t exist, or its value is not a string.

    Declaration

    Swift

    public func string(forKey key: String) -> String?

    Parameters

    key

    the key.

    Return Value

    the String object or nil.

  • Gets a property’s value as an integer. Floating point values will be rounded. The value true is returned as 1, false as 0. Returns 0 if the property doesn’t exist or does not have a numeric value.

    Declaration

    Swift

    public func int(forKey key: String) -> Int

    Parameters

    key

    the key.

    Return Value

    the Int value.

  • Gets a property’s value as a float. Integers will be converted to float. The value true is returned as 1.0, false as 0.0. Returns 0.0 if the property doesn’t exist or does not have a numeric value.

    Declaration

    Swift

    public func float(forKey key: String) -> Float

    Parameters

    key

    the key.

    Return Value

    the Float value.

  • Gets a property’s value as a double. Integers will be converted to double. The value true is returned as 1.0, false as 0.0. Returns 0.0 if the property doesn’t exist or does not have a numeric value.

    Declaration

    Swift

    public func double(forKey key: String) -> Double

    Parameters

    key

    the key.

    Return Value

    the Double value.

  • Gets a property’s value as a boolean. Returns true if the value exists, and is either true or a nonzero number.

    Declaration

    Swift

    public func boolean(forKey key: String) -> Bool

    Parameters

    key

    the key.

    Return Value

    the Bool value.

  • Get a property’s value as a blob. Returns nil if the property doesn’t exist, or its value is not a blob.

    Declaration

    Swift

    public func blob(forKey key: String) -> Blob?

    Parameters

    key

    the key.

    Return Value

    the Blob object or nil.

  • Gets a property’s value as an Date. JSON does not directly support dates, so the actual property value must be a string, which is then parsed according to the ISO-8601 date format (the default used in JSON.) Returns nil if the value doesn’t exist, is not a string, or is not parseable as a date. NOTE: This is not a generic date parser! It only recognizes the ISO-8601 format, with or without milliseconds.

    Declaration

    Swift

    public func date(forKey key: String) -> Date?

    Parameters

    key

    the key.

    Return Value

    the Date object or nil.

  • Get a property’s value as a ReadOnlyArrayObject, which is a mapping object of an array value. Returns nil if the property doesn’t exists, or its value is not an array.

    Declaration

    Swift

    public func array(forKey key: String) -> ReadOnlyArrayObject?

    Parameters

    key

    the key.

    Return Value

    the ReadOnlyArrayObject object or nil.

  • Get a property’s value as a ReadOnlyDictionaryObject, which is a mapping object of a dictionary value. Returns nil if the property doesn’t exists, or its value is not a dictionary.

    Declaration

    Swift

    public func dictionary(forKey key: String) -> ReadOnlyDictionaryObject?

    Parameters

    key

    the key.

    Return Value

    the ReadOnlyDictionaryObject object or nil.

  • Tests whether a property exists or not. This can be less expensive than -objectForKey:, because it does not have to allocate an NSObject for the property value.

    Declaration

    Swift

    public func contains(_ key: String) -> Bool

    Parameters

    key

    the key.

    Return Value

    the boolean value representing whether a property exists or not.

  • Gets content of the current object as a Dictionary. The values contained in the returned Dictionary object are all JSON based values.

    Declaration

    Swift

    public func toDictionary() -> Dictionary<String, Any>

    Return Value

    the Dictionary object representing the content of the current object in the JSON format.

  • Gets an iterator over the keys of the dictionary entries

    Declaration

    Swift

    public func makeIterator() -> IndexingIterator<[String]>

    Return Value

    a key iterator.

  • Subscript access to a ReadOnlyFragment object by key.

    Declaration

    Swift

    public subscript(key: String) -> ReadOnlyFragment

    Parameters

    key

    the key.

    Return Value

    the ReadOnlyFragment object.