Instance Method インスタンスメソッド

orderedSetByApplyingDifference:

Creates a new ordered set by applying a difference object to an existing ordered set. ある差異オブジェクトを既存の順序集合に加えることによって新しい順序集合を作成します。

Declaration 宣言

- (NSOrderedSet<ObjectType> *)orderedSetByApplyingDifference:(NSOrderedCollectionDifference<ObjectType> *)difference;

Discussion 議論

The following example computes the difference between two ordered sets, then applies the difference to create an ordered set that duplicates the original: 以下の例は、2つの順序集合の差異を計算します、それからその差異を適用することである順序集合を作成します、それはoriginalを正確に再現します:


NSOrderedSet *original = [NSOrderedSet orderedSetWithObjects:@"1", @"2", nil];
NSOrderedSet *modified = [NSOrderedSet orderedSetWithObjects:@"1", @"2", @"3", nil];


NSOrderedCollectionDifference *diff = [modified differenceFromOrderedSet:original];
// diff.hasChanges == true
// diff.insertions.count == 1
// diff.removals.count == 0


NSOrderedSet *updated = [original orderedSetByApplyingDifference:diff];
// updated == [@"1", @"2", @"3"]