RLMCollectionChange

Objective-C

@interface RLMCollectionChange : NSObject

스위프트

@_nonSendable(_assumed) class RLMCollectionChange : NSObject

A RLMCollectionChange 객체는 Realm 알림에서 보고하는 collection 변경 사항에 대한 정보를 캡슐화합니다.

RLMCollectionChange RLMArrayRLMResults-addNotificationBlock 에 등록된 알림 차단으로 전달되고 알림 차단이 마지막으로 호출된 이후 collection에서 변경된 행을 보고합니다.

변경 정보는 각 변경 유형에 대한 컬렉션의 행 인덱스 배열과 UITableView의 배치 업데이트 메서드에 직접 전달하기에 적합한 요청된 섹션의 인덱스 경로 배열, 두 가지 형식으로 제공됩니다. tv 이)라는 이름의 UITableView 을(를) 업데이트하는 전체 예입니다.

[tv beginUpdates];
[tv deleteRowsAtIndexPaths:[changes deletionsInSection:0] withRowAnimation:UITableViewRowAnimationAutomatic];
[tv insertRowsAtIndexPaths:[changes insertionsInSection:0] withRowAnimation:UITableViewRowAnimationAutomatic];
[tv reloadRowsAtIndexPaths:[changes modificationsInSection:0] withRowAnimation:UITableViewRowAnimationAutomatic];
[tv endUpdates];

RLMCollectionChange 의 모든 배열은 항상 오름차순으로 정렬됩니다.

  • 컬렉션의 이전 버전에 있고 이 버전에서 제거된 객체의 인덱스입니다.

    선언

    Objective-C

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

    스위프트

    var deletions: [NSNumber] { get }
  • 새로 삽입된 컬렉션의 새 버전에 있는 인덱스입니다.

    선언

    Objective-C

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

    스위프트

    var insertions: [NSNumber] { get }
  • 수정된 collection의 새 버전에 있는 인덱스입니다.

    RLMResults 의 경우, 해당 인덱스에 있는 객체의 속성 중 하나 이상이 수정되었거나 해당 객체에 의해 연결된 객체가 수정되었음을 의미합니다.

    RLMArray 의 경우, 인덱스에 다른 객체를 포함하도록 배열 자체를 수정하는 것도 수정으로 보고됩니다.

    선언

    Objective-C

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

    스위프트

    var modifications: [NSNumber] { get }
  • 지정된 섹션에 있는 삭제 인덱스의 인덱스 경로를 반환합니다.

    선언

    Objective-C

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

    스위프트

    func deletions(inSection section: UInt) -> [IndexPath]
  • 지정된 섹션에 있는 삽입 인덱스의 인덱스 경로를 반환합니다.

    선언

    Objective-C

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

    스위프트

    func insertions(inSection section: UInt) -> [IndexPath]
  • 지정된 섹션에 있는 수정 인덱스의 인덱스 경로를 반환합니다.

    선언

    Objective-C

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

    스위프트

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