Я получаю следующую ошибку при попытке выполнить этот учебник:
О, что-то пошло не так: A response for the QueryOn<Thing> did return successfully, but a serious error occurred when decoding the array of Thing.
Double check that you are passing Thing.self, and references to all other EntryDecodable classes into the Client initializer.
при использовании следующего кода длявызов содержательный:
func fetch() {
let query = QueryOn<Thing>.where(field: .description, .exists(true))
client.fetchArray(of: Thing.self, matching: query) { (result: Result<ArrayResponse<Thing>>) in
switch result {
case .success(let things):
guard let firstThing = things.items.first else { return }
print(firstThing)
case .error(let error):
print("Oh no something went wrong: \(error)")
}
}
}
Моя модель Thing установлена следующим образом: ![enter image description here](https://i.stack.imgur.com/9QXUJ.png)
, и у меня в настоящее время добавлено два Things
: ![enter image description here](https://i.stack.imgur.com/QW6EI.png)
Мой класс Thing выглядит так:
final class Thing: EntryDecodable, FieldKeysQueryable {
enum FieldKeys: String, CodingKey {
case name, description
}
static let contentTypeId: String = "thing"
let id: String
let localeCode: String?
let updatedAt: Date?
let createdAt: Date?
let name: String
let description: String
public required init(from decoder: Decoder) throws {
let sys = try decoder.sys()
id = sys.id
localeCode = sys.locale
updatedAt = sys.updatedAt
createdAt = sys.createdAt
let fields = try decoder.contentfulFieldsContainer(keyedBy: Thing.FieldKeys.self)
self.name = try! fields.decodeIfPresent(String.self, forKey: .name)!
self.description = try! fields.decodeIfPresent(String.self, forKey: .description)!
}
}
Кто-нибудь может увидеть, что мне не хватает?