枚举

以下枚举在全局范围内可用。

发布者

  • 结合 Realm 类型的发布者。

    通常不应直接创建任何此类类型,而应使用创建这些类型的扩展方法。

    查看更多

    声明

    Swift

    @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
    public enum RealmPublishers

通知

  • RealmMapChange值封装有关 Realm 通知所报告的字典变更的信息。

    查看更多

    声明

    Swift

    @frozen
    public enum RealmMapChange<Collection> where Collection : RealmKeyedCollection
  • 有关对传递到Object的通知块的对象更改的信息。

    查看更多

    声明

    Swift

    @frozen
    public enum ObjectChange<T>
  • RealmCollectionChange值封装有关 Realm 通知报告的collection变更的信息。

    更改信息有两种格式:集合中每种更改类型的行索引的简单数组,以及请求部分中适合直接传递给UITableView的批量更新方法的索引路径数组。

    .update情况下的索引数组遵循UITableView的批处理约定,并且可以在转换为索引路径后按原样传递给表视图的批量更新函数。 例如,对于简单的单节表视图,您可以执行以下操作:

    self.notificationToken = results.observe { changes in
        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.insertRows(at: insertions.map { IndexPath(row: $0, section: 0) },
               with: .automatic)
            self.tableView.deleteRows(at: deletions.map { IndexPath(row: $0, section: 0) },
               with: .automatic)
            self.tableView.reloadRows(at: modifications.map { IndexPath(row: $0, section: 0) },
               with: .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
        }
    }
    
    查看更多

    声明

    Swift

    @frozen
    public enum RealmCollectionChange<CollectionType>
  • SectionedResultsChange值封装有关 Realm 通知报告的分段结果变更的信息。

    第一次传递通知时,将为.initial ,所有后续通知都将为.change() ,并提供有关自上次调用回调以来已更改内容的信息。 }

    查看更多

    声明

    Swift

    @frozen
    public enum SectionedResultsChange<Collection>