List

List<T> is the container type in Realm used to define to-many relationships.

Lists hold a single Object subclass (T) which defines the type of the list.

Lists can be filtered and sorted with the same predicates as Results<T>.

When added as a property on Object models, the property must be declared as let and cannot be dynamic.

  • Returns a GeneratorOf<T> that yields successive elements in the list.

    Declaration

    Swift

    public func generate() -> GeneratorOf<T>
  • The position of the first element in a non-empty collection. Identical to endIndex in an empty collection.

    Declaration

    Swift

    public var startIndex: Int { return 0 }
  • The collection’s past the end position. endIndex is not a valid argument to subscript, and is always reachable from startIndex by zero or more applications of successor().

    Declaration

    Swift

    public var endIndex: Int { return count }
  • This method has no effect.

    Declaration

    Swift

    public func reserveCapacity(capacity: Int) { }