swift - NSTableView animation inconsistant -


i have nstableview intermittently stop animating , updating correctly, leading terrible user experience.

let oldrows = filtereddocuments let newrows = newfiltereddocuments let diff = oldrows.diff(newrows) filtereddocuments = newfiltereddocuments  if (diff.results.count > 0) {     let deletionindexpaths = nsmutableindexset()     diff.deletions.foreach { deletionindexpaths.addindex($0.idx) }     let insertionindexpaths = nsmutableindexset()     diff.insertions.foreach { insertionindexpaths.addindex($0.idx) }      self.tableview?.beginupdates()     self.tableview?.removerowsatindexes(deletionindexpaths, withanimation: nstableviewanimationoptions.effectfade)     self.tableview?.insertrowsatindexes(insertionindexpaths, withanimation: nstableviewanimationoptions.slideleft)     self.tableview?.endupdates() } 

there seems no logic when stops animating, , in many tests i've done feels it's build related. interestingly never stops animating when profiling...

it's if on main thread clogging ui , nstableview times out , cancels update - have no idea how can debug this.

how if 1 , other? did similar when needed insert cell , scroll, lead poor user experience. solution add slight delay. not sure if you're trying accomplish base on small code snippet, here go:

let oldrows = filtereddocuments let newrows = newfiltereddocuments let diff = oldrows.diff(newrows) filtereddocuments = newfiltereddocuments  if (diff.results.count > 0) {     let deletionindexpaths = nsmutableindexset()     diff.deletions.foreach { deletionindexpaths.addindex($0.idx) }     let insertionindexpaths = nsmutableindexset()     diff.insertions.foreach { insertionindexpaths.addindex($0.idx) }      self.tableview?.beginupdates()     self.tableview?.removerowsatindexes(deletionindexpaths, withanimation: nstableviewanimationoptions.effectfade)     self.tableview?.endupdates()      let delay = 0.35     let time = dispatch_time(dispatch_time_now, int64(delay * double(nsec_per_sec))) // hate syntax     dispatch_after(delay, dispatch_get_main_queue(), { [weak self] in         self?.tableview?.beginupdates()         self?.tableview?.insertrowsatindexes(insertionindexpaths, withanimation: nstableviewanimationoptions.slideleft)         self?.tableview?.endupdates()     }) } 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -