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"]