delete(_:)

public func delete<S: Sequence>(_ objects: S) where S.Iterator.Element: Object

Deletes zero or more objects from the Realm.

Do not pass in a slice to a Results or any other auto-updating Realm collection type (for example, the type returned by the Swift suffix(_:) standard library method). Instead, make a copy of the objects to delete using Array(), and pass that instead. Directly passing in a view into an auto-updating collection may result in ‘index out of bounds’ exceptions being thrown.

Warning

This method may only be called during a write transaction.

  • S

    Declaration

    Swift

    public func delete<S: Sequence>(_ objects: S) where S.Iterator.Element: Object