flocked / AdvancedCollectionTableView

Extended NSCollectionView & NSTableView: Cell- & ItemRegistration, SwiftUI table cells/collection view items,…
MIT License
26 stars 1 forks source link

Fix building error & NSTableView swizzled issue #10

Closed Mx-Iris closed 8 months ago

Mx-Iris commented 8 months ago

I tried to fix the building error, and also NSTableViewDataSource should not strongly reference NSTableView.

Mx-Iris commented 8 months ago

I created a custom TableView causing swizzled to execute repeatedly, should not use self as the object of the associated object, should use NSTableView.self to ensure it only executes once!

flocked commented 8 months ago

Thanks! I can't replicate the error regarding swizzling. How did you swizzle your table view?

Mx-Iris commented 8 months ago

@flocked You need to create a custom class that inherits from NSTableView, then create an NSTableView, and use TableViewDiffableDataSource to reproduce the error. Since the custom TableView and NSTableView are different class objects, their didSwizzle properties are not the same.

Mx-Iris commented 8 months ago

TableViewSwizzledIssue.zip This is a reproduced example, because the repeated exchange method caused makeView(withIdentifier: identifier, owner: nil) to call to Apple's original implementation, which did not create CellClass.