This library aims to provide a simplified interface for determing the difference between two collections, and then easily surfacing those changes to the user.
- Wrap up an implementation of the Levenshtein Distance algorithm.
- Easily animate these changes using the built in UITableView and UICollectionView.
Create a Transformer
object, supplying it with the source and the destination collection:
let transformer1 = Transformer(source: "hello", destination: "olleh")
At this point, you can simply query the transformer for the minimum number of edits to complete the transformer, or for the steps themselves (lazily calculated):
print(transformer1.minEditDistance) //4
print(transformer1.editSteps) // [AnyEditor<String>]
You can now easily apply this transformation to a UITableView or UICollectionView in a single line:
let tv = UITableView(frame: .zero)
tv.processUpdates(for: transformer1, inSection: 0)
let cv = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
cv.processUpdates(for: transformer1, inSection: 0)
To run the example project, clone the repo, and run pod install
from the Example directory first.
- iOS 8.0+
- Swift 4 (Xcode 9)
Edits is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "Edits"
William McGinty, mcgintw@gmail.com
Edits is available under the MIT license. See the LICENSE file for more info.