Discussion 議論
The following example computes the difference between two arrays, then applies the difference to create an array that duplicates the original: 以下の例は、2つの配列の差異を計算します、それからその差異を適用することである配列を作成します、それはoriginalを正確に再現します:
NSArray *original = @[@"1", @"2"];
NSArray *modified = @[@"1", @"2", @"3"];
NSOrderedCollectionDifference *diff = [modified differenceFromArray:original];
// diff.hasChanges == true
// diff.insertions.count ==
// diff.removals.count == 0
NSArray *updated = [original arrayByApplyingDifference:diff];
// updated == [@"1", @"2", @"3"]