RLMSectionedResultsChange

Objective-C

@interface RLMSectionedResultsChange : NSObject

Swift

@_nonSendable(_assumed) class RLMSectionedResultsChange : NSObject

A RLMSectionedResultsChange object encapsulates information about changes to sectioned results that are reported by Realm notifications.

RLMSectionedResultsChange is passed to the notification blocks registered with -addNotificationBlock on RLMSectionedResults, and reports what sections and rows in the collection changed since the last time the notification block was called.

A complete example of updating a UITableView named tv:

[tv beginUpdates];
[tv deleteRowsAtIndexPaths:changes.deletions withRowAnimation:UITableViewRowAnimationAutomatic];
[tv insertRowsAtIndexPaths:changes.insertions withRowAnimation:UITableViewRowAnimationAutomatic];
[tv reloadRowsAtIndexPaths:changes.modifications withRowAnimation:UITableViewRowAnimationAutomatic];
[tv insertSections:changes.sectionsToInsert withRowAnimation:UITableViewRowAnimationAutomatic];
[tv deleteSections:changes.sectionsToRemove withRowAnimation:UITableViewRowAnimationAutomatic];
[tv endUpdates];

All of the arrays in an RLMSectionedResultsChange are always sorted in ascending order.

  • The index paths of objects in the previous version of the collection which have been removed from this one.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSArray<NSIndexPath *> *_Nonnull deletions;

    Swift

    var deletions: [IndexPath] { get }
  • The index paths in the new version of the collection which were newly inserted.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSArray<NSIndexPath *> *_Nonnull insertions;

    Swift

    var insertions: [IndexPath] { get }
  • The index paths in the old version of the collection which were modified.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSArray<NSIndexPath *> *_Nonnull modifications;

    Swift

    var modifications: [IndexPath] { get }
  • The indices of the sections to be inserted.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSIndexSet *_Nonnull sectionsToInsert;

    Swift

    var sectionsToInsert: IndexSet { get }
  • The indices of the sections to be removed.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSIndexSet *_Nonnull sectionsToRemove;

    Swift

    var sectionsToRemove: IndexSet { get }
  • Returns the index paths of the deletion indices in the given section.

    Declaration

    Objective-C

    - (nonnull NSArray<NSIndexPath *> *)deletionsInSection:(NSUInteger)section;

    Swift

    func deletions(inSection section: UInt) -> [IndexPath]
  • Returns the index paths of the insertion indices in the given section.

    Declaration

    Objective-C

    - (nonnull NSArray<NSIndexPath *> *)insertionsInSection:(NSUInteger)section;

    Swift

    func insertions(inSection section: UInt) -> [IndexPath]
  • Returns the index paths of the modification indices in the given section.

    Declaration

    Objective-C

    - (nonnull NSArray<NSIndexPath *> *)modificationsInSection:(NSUInteger)section;

    Swift

    func modifications(inSection section: UInt) -> [IndexPath]