一个Swift框架,用于计算在CollectionType中发生的变更。集合的元素还应该遵守Equatable协议。灵感来自Changeset。
Cartfile中添加github "chrisamanse/Changes" ~> 2.0。Podfile中添加pod "Changes"。.Package(url: "https://github.com/chrisamanse/Changes.git, majorVersion: 2)。获取包含属于Equatable元素的Collection的变更。
let oldArray = [1,2,3,4,5]
let newArray = [1,3,2,4]
// Get changes
let changes = newArray.changes(since: oldArray)
// Prints out ["Moved 3 from index 2 to 1", "Deleted 5 at index 4"]
print(changes)版权 © 2016 Joe Christopher Paul Amanse
本软件遵循MIT License。