ReadOnlyFragment

public class ReadOnlyFragment: ReadOnlyFragmentProtocol,
                               ReadOnlyArrayFragment, ReadOnlyDictionaryFragment

ReadOnlyFragment provides readonly access to data value. ReadOnlyFragment also provides subscript access by either key or index to the nested values which are wrapped by ReadOnlyFragment objects.

  • Gets the fragment value. The value types are Blob, ReadOnlyArray, ReadOnlyDictionary, Number, or String based on the underlying data type; or nil if the value is nil.

    Declaration

    Swift

    public var value: Any?
  • Gets the value as a string. Returns nil if the value is nil, or the value is not a string.

    Declaration

    Swift

    public var string: String?
  • int

    Gets the value as an integer. Floating point values will be rounded. The value true is returned as 1, false as 0. Returns 0 if the value is nil or is not a numeric value.

    Declaration

    Swift

    public var int: Int
  • Gets the 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 value is nil or is not a numeric value.

    Declaration

    Swift

    public var float: Float
  • Gets the 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 value is nil or is not a numeric value.

    Declaration

    Swift

    public var double: Double
  • Gets the value as a boolean. Returns true if the value is not nil nor NSNull, and is either true or a nonzero number.

    Declaration

    Swift

    public var boolean: Bool
  • Get the value as a Blob. Returns nil if the value is nil, or the value is not a Blob.

    Declaration

    Swift

    public var blob: Blob?
  • Gets the 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 is nil, 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 var date: Date?
  • Get the value as a ReadOnlyArrayObject, a mapping object of an array value. Returns nil if the value is nil, or the value is not an array.

    Declaration

    Swift

    public var array: ReadOnlyArrayObject?
  • Get a property’s value as a ReadOnlyDictionaryObject, a mapping object of a dictionary value. Returns nil if the value is nil, or the value is not a dictionary.

    Declaration

    Swift

    public var dictionary: ReadOnlyDictionaryObject?
  • Checks whether the value held by the fragment object exists or is nil value or not.

    Declaration

    Swift

    public var exists: Bool
  • Subscript access to a ReadOnlyFragment object by index.

    Declaration

    Swift

    public subscript(index: Int) -> ReadOnlyFragment

    Parameters

    index

    The index

  • Subscript access to a ReadOnlyFragment object by key.

    Declaration

    Swift

    public subscript(key: String) -> ReadOnlyFragment

    Parameters

    key

    The key.