Enums

The following enums are available globally.

  • Enumeration that describes the error codes within the Realm error domain. The values can be used to catch a variety of recoverable errors, especially those happening when initializing a Realm instance.

    let realm: Realm?
    do {
        realm = Realm()
    } catch RealmSwift.Error.IncompatibleLockFile() {
        print("Realm Browser app may be attached to Realm on device?")
    }
    
    See more

    Declaration

    Swift

    public enum Error: ErrorType
  • RealmCollectionChange is passed to the notification blocks for Realm collections, and reports the current state of the collection and what changes were made to the collection since the last time the notification was called.

    The arrays of indices in the .Update case follow UITableView’s batching conventions, and can be passed as-is to a table view’s batch update functions after converting to index paths in the appropriate section. For example, for a simple one-section table view, you can do the following:

    self.notificationToken = results.addNotificationBlock { changes switch changes { case .Initial: // Results are now populated and can be accessed without blocking the UI self.tableView.reloadData() break case .Update(_, let deletions, let insertions, let modifications): // Query results have changed, so apply them to the TableView self.tableView.beginUpdates() self.tableView.insertRowsAtIndexPaths(insertions.map { NSIndexPath(forRow: $0, inSection: 0) }, withRowAnimation: .Automatic) self.tableView.deleteRowsAtIndexPaths(deletions.map { NSIndexPath(forRow: $0, inSection: 0) }, withRowAnimation: .Automatic) self.tableView.reloadRowsAtIndexPaths(modifications.map { NSIndexPath(forRow: $0, inSection: 0) }, withRowAnimation: .Automatic) self.tableView.endUpdates() break case .Error(let err): // An error occurred while opening the Realm file on the background worker thread fatalError(\(err)) break } }

    See more

    Declaration

    Swift

    public enum RealmCollectionChange<T>