Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

wmcginty/Edits

Repository files navigation

Edits

CI Status Version License Platform

Purpose

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.

Usage

1. Create A Transformer

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)

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • iOS 8.0+
  • Swift 4 (Xcode 9)

Installation

Edits is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "Edits"

Author

William McGinty, mcgintw@gmail.com

License

Edits is available under the MIT license. See the LICENSE file for more info.

About

A micro-framework to determine and display the smallest set of edits between two collections.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published