Closed sschizas closed 6 years ago
@sschizas Hi, I believe what you are asking is like this ?
func testInsert() {
let old = Array("a")
let new = Array("ba")
let changes = diff(old: old, new: new)
XCTAssertEqual(changes.count, 1)
XCTAssertNotNil(changes[0].insert)
}
I think that suits the way UITableView/UICollection
does its animation. If you create a new project using the default template Master - Detail
, you can see this function which does the job of inserting 1 item to the beginning of the list
func insertNewObject(_ sender: Any) {
objects.insert(NSDate(), at: 0)
let indexPath = IndexPath(row: 0, section: 0)
tableView.insertRows(at: [indexPath], with: .automatic)
}
Hi @onmyway133 ,
I am using DeepDiff and I have the following problem I can't figure out what is wrong:
I have a class (Hashable):
class Foo: Hashable { let models: [String] }
In the begging I have one instance of class Foo called A in an array and DeepDiff correctly instructs for an insert as the initial state is an empty uitableview. Then I have two instances of class Foo called A and B in the following order: [B, A], and DeepDiff correctly instructs for an insert for instance B but for instance A it doesn't instruct anything ex. move. I am missing something? Is this a bug?