We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello there,
I upgraded the Algolia Swift client to 9.9.1 and I'm having trouble understanding how I serialize response hits into my custom objects.
9.9.1
Previously, I was able to do something like this:
index?.search(query: query) { [weak self] result in switch result { case .failure(let error): self?.logger.error("Error returning search results: \(error)") case .success(let response): do { let results: [MyLocalObject] = try response.extractHits() self?.results = results DispatchQueue.main.async { self?.tableView.reloadData() } } catch let error { self?.logger.error("error: \(error)") } } }
But extractHits seems to be gone now and I couldn't find a place in the documentation that would explain if and what it was replaced by.
extractHits
I'm assuming I'm missing something super obvious.
Thanks for your help and support.
The text was updated successfully, but these errors were encountered:
Hey @Broich 👋🏻 With the new client, you can leverage generics:
import Foundation import Core import Search let appID = "YOU_APP_ID" let apiKey = "YOUR_API_KEY" let indexName = "YOUR_INDEX_NAME" struct MyLocalObject: Codable { let title: String let original_language: String let genres: [String] } let client = try SearchClient(appID: appID, apiKey: apiKey) let res: SearchResponse<MyLocalObject> = try await client.searchSingleIndex(indexName: indexName) dump(res.hits)
Note
Your struct must conform to the Codable protocol
Sorry, something went wrong.
Very helpful, thank you!
Fluf22
No branches or pull requests
Hello there,
I upgraded the Algolia Swift client to
9.9.1
and I'm having trouble understanding how I serialize response hits into my custom objects.Previously, I was able to do something like this:
But
extractHits
seems to be gone now and I couldn't find a place in the documentation that would explain if and what it was replaced by.I'm assuming I'm missing something super obvious.
Thanks for your help and support.
The text was updated successfully, but these errors were encountered: