一个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。