Result

public final class Result : ArrayProtocol, DictionaryProtocol, Sequence

Result represents a single row in the query result. The projecting result value can be accessed either by using a zero based index or by a key corresponding to the SelectResult objects given when constructing the Query object.

A key used for accessing the projecting result value could be one of the followings:

  • The alias name of the SelectResult object.
  • The last component of the keypath or property name of the property expression used when creating the SelectResult object.
  • The provision key in $1, $2, …$N format for the SelectResult that doesn’t have an alias name specified or is not a property expression such as an aggregate function expression (e.g. count(), avg(), min(), max(), sum() and etc). The number suffix after the ‘$’ character is a running number starting from one.
  • A number of the projecting values in the result.

    Declaration

    Swift

    public var count: Int
  • The projecting result value at the given index.

    Declaration

    Swift

    public func value(at index: Int) -> Any?

    Parameters

    index

    The select result index.

    Return Value

    The value.

  • The projecting result value at the given index as a String value. Returns nil if the value is not a string.

    Declaration

    Swift

    public func string(at index: Int) -> String?

    Parameters

    index

    The select result index.

    Return Value

    The String object or nil.

  • The projecting result value at the given index as a Number value. Returns nil if the value is not a number.

    Declaration

    Swift

    public func number(at index: Int) -> NSNumber?

    Parameters

    index

    The select result index.

    Return Value

    The Number value.

  • The projecting result value at the given index as an Int value. Returns 0 if the value is not a numeric value.

    Declaration

    Swift

    public func int(at index: Int) -> Int

    Parameters

    index

    The select result index.

    Return Value

    The Int value.

  • The projecting result value at the given index as an Int64 value. Returns 0 if the value is not a numeric value.

    Declaration

    Swift

    public func int64(at index: Int) -> Int64

    Parameters

    index

    The select result index.

    Return Value

    The Int value.

  • The projecting result value at the given index as a Double value. Returns 0.0 if the value is not a numeric value.

    Declaration

    Swift

    public func double(at index: Int) -> Double

    Parameters

    index

    The select result index.

    Return Value

    The Double value.

  • The projecting result value at the given index as a Float value. Returns 0.0 if the value is not a numeric value.

    Declaration

    Swift

    public func float(at index: Int) -> Float

    Parameters

    index

    The select result index.

    Return Value

    The Float value.

  • The projecting result value at the given index as a Boolean value. Returns true if the value is not null, and is either true or a nonzero number.

    Declaration

    Swift

    public func boolean(at index: Int) -> Bool

    Parameters

    index

    The select result index.

    Return Value

    The Bool value.

  • The projecting result value at the given index as a Blob value. Returns nil if the value is not a blob.

    Declaration

    Swift

    public func blob(at index: Int) -> Blob?

    Parameters

    index

    The select result index.

    Return Value

    The Blob value or nil.

  • The projecting result value at the given index as a Date value. Returns nil if the value is not a string and is not parseable as a date.

    Declaration

    Swift

    public func date(at index: Int) -> Date?

    Parameters

    index

    The select result index.

    Return Value

    The Date value or nil.

  • The projecting result value at the given index as a readonly ArrayObject value. Returns nil if the value is not an array.

    Declaration

    Swift

    public func array(at index: Int) -> ArrayObject?

    Parameters

    index

    The select result index.

    Return Value

    The ReadOnlyArrayObject or nil.

  • The projecting result value at the given index as a readonly DictionaryObject value. Returns nil if the value is not a dictionary.

    Declaration

    Swift

    public func dictionary(at index: Int) -> DictionaryObject?

    Parameters

    index

    The select result index.

    Return Value

    The ReadOnlyDictionaryObject or nil.

  • Gets all values as an Array. The value types of the values contained in the returned Array object are Array, Blob, Dictionary, Number types, NSNull, and String.

    Declaration

    Swift

    public func toArray() -> Array<Any>

    Return Value

    The Array representing all values.

  • Subscript access to a ReadOnlyFragment object of the projecting result value at the given index.

    Declaration

    Swift

    public subscript(index: Int) -> Fragment

    Parameters

    index

    The select result index.

  • All projecting keys.

    Declaration

    Swift

    public var keys: Array<String>
  • The projecting result value for the given key. Returns nil if the key doesn’t exist.

    Declaration

    Swift

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

    Parameters

    key

    The select result key.

    Return Value

    The value or nil.

  • The projecting result value for the given key as a String value. Returns nil if the key doesn’t exist, or the value is not a string.

    Declaration

    Swift

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

    Parameters

    key

    The select result key.

    Return Value

    The String value or nil.

  • The projecting result value for the given key as a Number value. Returns nil if the key doesn’t exist, or the value is not a number.

    Declaration

    Swift

    public func number(forKey key: String) -> NSNumber?

    Parameters

    key

    The select result key.

    Return Value

    The Number value or nil.

  • The projecting result value for the given key as an Int value. Returns 0 if the key doesn’t exist, or the value is not a numeric value.

    Declaration

    Swift

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

    Parameters

    key

    The select result key.

    Return Value

    The Int value.

  • The projecting result value for the given key as an Int64 value. Returns 0 if the key doesn’t exist, or the value is not a numeric value.

    Declaration

    Swift

    public func int64(forKey key: String) -> Int64

    Parameters

    key

    The select result key.

    Return Value

    The Int value.

  • The projecting result value for the given key as a Float value. Returns 0.0 if the key doesn’t exist, or the value is not a numeric value.

    Declaration

    Swift

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

    Parameters

    key

    The select result key.

    Return Value

    The float value.

  • The projecting result value for the given key as a Double value. Returns 0.0 if the key doesn’t exist, or the value is not a numeric value.

    Declaration

    Swift

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

    Parameters

    key

    The select result key.

    Return Value

    The Double value.

  • The projecting result value for the given key as a Boolean value. Returns true if the key doesn’t exist, or the value is not null, and is either true or a nonzero number.

    Declaration

    Swift

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

    Parameters

    key

    The select result key.

    Return Value

    The Bool value.

  • The projecting result value for the given key as a Blob value. Returns nil if the key doesn’t exist, or the value is not a blob.

    Declaration

    Swift

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

    Parameters

    key

    The select result key.

    Return Value

    The Blob value or nil.

  • The projecting result value for the given key as a Date value. Returns nil if the key doesn’t exist, or the value is not a string and is not parseable as a date.

    Declaration

    Swift

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

    Parameters

    key

    The select result key.

    Return Value

    The Date value or nil.

  • The projecting result value for the given key as a readonly ArrayObject value. Returns nil if the key doesn’t exist, or the value is not an array.

    Declaration

    Swift

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

    Parameters

    key

    The select result key.

    Return Value

    The ReadOnlyArrayObject value or nil.

  • The projecting result value for the given key as a readonly DictionaryObject value. Returns nil if the key doesn’t exist, or the value is not a dictionary.

    Declaration

    Swift

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

    Parameters

    key

    The select result key.

    Return Value

    The ReadOnlyDictionaryObject or nil.

  • Tests whether a projecting result key exists or not.

    Declaration

    Swift

    public func contains(key: String) -> Bool

    Parameters

    key

    The select result key.

    Return Value

    True if exists, otherwise false.

  • Gets all values as a Dictionary. The value types of the values contained in the returned Dictionary object are Array, Blob, Dictionary, Number types, NSNull, and String.

    Declaration

    Swift

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

    Return Value

    The Dictionary representing all values.

  • Gets an iterator over the prjecting result keys.

    Declaration

    Swift

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

    Return Value

    The IndexingIterator object of all result keys.

  • Subscript access to a ReadOnlyFragment object of the projecting result value for the given key.

    Declaration

    Swift

    public subscript(key: String) -> Fragment

    Parameters

    key

    The select result key.