Consider you are having the table view with a separate cell class that will be registered for table view later.
Now, we know how to disable the table view scroll using the table view instance, like in the below line.
tableView.isScrollEnabled = true/false
But what if I require to show some coach marks on the cell class, And I need to lock the table view scroll until that coach marks disappear using cell rather than table view. Because for a cell class table view instance is inaccessible since cell is within table view, not the table view within cell.
I’ve achieved this by using Notifications and Observers. But Please let me know if this can be achieved in any other way.
2
Answers
Is your target supporting iOS 13+? If so you can use Combine SDK. It will give you the same principle of notification and observers.
You will need a viewModel conforms to ObservableObject, then you will use @Published property wrapper, lets us easily construct types that emit signals whenever some of their properties were changed.
ViewModel.swift
ViewController.swift
Here is simple trick that can answer your question:
More isolation and loose-coupling:
For a real solution:
In your BookViewModel.swift
In your BookViewController.swift
In your BookItemTableCell.swift