---
title: "differenceFromArray:"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsarray/differencefromarray:"
---

# differenceFromArray:

Compares two arrays to create a difference object that represents the changes between them.

## Declaration

```occ
- (NSOrderedCollectionDifference<id> *) differenceFromArray:(NSArray<id> *) other;
```

## Discussion

Discussion The difference method creates the difference object by comparing objects within the arrays with the isEqual: method. The following example computes the difference between two arrays: NSArray *original = @[@"1", @"2"]; NSArray *modified = @[@"1", @"2", @"3"];

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

## See Also

### Comparing with Another Array

- [differenceFromArray:withOptions:](foundation/nsarray/differencefromarray:withoptions:.md)
- [differenceFromArray:withOptions:usingEquivalenceTest:](foundation/nsarray/differencefromarray:withoptions:usingequivalencetest:.md)
- [NSOrderedCollectionDifference](foundation/nsorderedcollectiondifference.md)
- [NSOrderedCollectionDifferenceCalculationOptions](foundation/nsorderedcollectiondifferencecalculationoptions.md)
