algolia / algoliasearch-client-swift

⚑️ A fully-featured and blazing-fast Swift API client to interact with Algolia.
MIT License
205 stars 65 forks source link

Overriding a public method in the HitsTableViewController #653

Closed georgepliuster closed 4 years ago

georgepliuster commented 4 years ago

Describe the bug πŸ› I have an existing ViewController that uses TableViewDelegate, UITableViewDataSource with an array collection as a data source - a classical setup. I want to add a search bar and the inherit the HitTableViewController, allowing me to present my data either via the array collection or using the search bar. Depending on the mode of search (array or instant search) I will populate the table accordingly. Unfortunately the data source methods within the HitsTableViewController are declared public. Therefore I cannot override them in my inherited view controller. I tried extending my ViewController, but that does not work.

Aside from changing the data source method to open from public in the HitsTableViewController, do I have any other options?

Thanks

To Reproduce πŸ” Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior πŸ’­ A clear and concise description of what you expected to happen.

Screenshots πŸ–₯ If applicable, add screenshots to help explain your problem.

Environment:

Additional context Add any other context about the problem here.

VladislavFitz commented 4 years ago

Hello @georgepliuster

Sorry for delayed response. The usage of HitsTableViewController is not mandatory, you can just add a conformance to HitsController protocol to your own ViewController and then connect it to your HitsInteractor. Pro tip: if your ViewController presents the hits in the instance of UITableView, add conformance to HitsTableViewContainer protocol to your view controller, returning your table view via hitsTableView property:

var hitsTableView: UITableView {
  return myTableView
}

By doing this, you get the implementations of reload and scrollToTop methods of HitsController protocol for free.

georgepliuster commented 4 years ago

Hello Vladislav,

Good to hear from you. No worries about the delayed response.

Adding a conformance to the HitsController protocol is a great idea and I will give it a try.

Thanks!

On Wed, Aug 26, 2020 at 11:03 AM Vladislav Fitc notifications@github.com wrote:

Hello @georgepliuster https://github.com/georgepliuster

Sorry for delayed response. The usage of HitsTableViewController is not mandatory, you can just add a conformance to HitsController protocol to your own ViewController and then connect it to your HitsInteractor. Pro tip: if your ViewController presents the hits in the instance of UITableView, add conformance to HitsTableViewContainer protocol to your view controller, returning your table view via hitsTableView property:

var hitsTableView: UITableView { return myTableView }

By doing this, you get the implementations of reload and scrollToTop methods of HitsController protocol for free.

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/algolia/algoliasearch-client-swift/issues/653#issuecomment-680936571, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAL5EFW63ZMHGTKDLIZQ4HTSCUP2TANCNFSM4PT4TKLA .

VladislavFitz commented 4 years ago

You are welcome!