Originally created by @CoderCMY on GitHub (Jul 15, 2019).
I query a table like this, and I got the result succeed at first ,when i call the tableView's reloadData method , I found all the book's properties is nil in "cellForRowAt" method, I'm so
confused ,who konws why???
Originally created by @CoderCMY on GitHub (Jul 15, 2019).
I query a table like this, and I got the result succeed at first ,when i call the tableView's reloadData method , I found all the book's properties is nil in "cellForRowAt" method, I'm so
confused ,who konws why???
```swift
func getAllBooks(completion: @escaping (_ books: [Book]?) -> Void) {
var books: [Book]?
CoreStore.perform(asynchronous: { (transaction) -> Void in
books = transaction.fetchAll(From<Book>().orderBy(.descending(\.updateTime)))
}) { (result) in
switch result {
case .success:
completion(books)
case .failure:
completion(books)
}
}
}
```
adam
added the question label 2025-12-29 15:28:07 +01:00
@JohnEstropia commented on GitHub (Jul 18, 2019):
You will need to convert your `books` to main thread instances before you use them:
```
func getAllBooks(completion: @escaping (_ books: [Book]?) -> Void) {
CoreStore.perform(asynchronous: { (transaction) -> [Book] in
return transaction.fetchAll(From<Book>().orderBy(.descending(\.updateTime)))
}) { (books) in
completion(CoreStore.fetchExisting(books))
}
}
```
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @CoderCMY on GitHub (Jul 15, 2019).
I query a table like this, and I got the result succeed at first ,when i call the tableView's reloadData method , I found all the book's properties is nil in "cellForRowAt" method, I'm so
confused ,who konws why???
@JohnEstropia commented on GitHub (Jul 18, 2019):
You will need to convert your
booksto main thread instances before you use them:@CoderCMY commented on GitHub (Jul 18, 2019):
I've solved this problem with your method, Thank you very much