API Reference / iOS InstantSearch Widgets / Stats
Apr. 11, 2019

About this widget

The Stats widgets display the total number of matching hits and the time it took to get them (time spent in the Algolia server). Possible ones are:

  • StatsButtonWidget, which inherits from UIButton.
  • StatsLabelWidget, which inherits from UILabel.

Examples

1
2
3
var statsWidget = StatsLabelWidget(frame: CGRect)
statsWidget.resultTemplate = "{nbHits} results in {processingTimeMS}"
statsWidget.errorText = "Error while loading"

Parameters

resultTemplate
type: String
default: "{nbHits} results"
Optional

What the widget displays when a search request returns successfully. It takes the form of a templated string with the following templates to replace:

  • {nbHits}: the hit count for the current query.
  • {processingTimeMS}: the time the server took to process the request, in milliseconds.
  • {hitsPerPage}: the maximum number of hits returned per page.
  • {nbPages}: the number of pages corresponding to the number of hits.
  • {page}: the index of the current page (zero-based).
  • {query}: the query text.
1
statsWidget.resultTemplate = "{nbHits} results in {processingTimeMS}"
errorText
type: String
default:
Optional

What the widget displays when a search query returns with an error.

1
statsWidget.errorText = "Error while loading"

Did you find this page helpful?