Open JohnEstropia opened 8 years ago
@JohnEstropia Hi JohnEstropia, it's a great open source for core data. Does CoreStore only support fetch records on the main thread? If a large number of records, does it block the main thread?
@evanxie-cn If you have very large fetches (e.g. image binary data, few thousand objects) you can always fetch from a background transaction and pass the info you need to the main thread. Here's an example:
dataStack.perform(
asynchronous: { (transaction) -> [UIImage] in
let people = transaction.fetchAll(From<Person>().where(/* ... */))
return people.map { UIImage(data: $0.imageData)! }
},
completion: { (photos) in /* ... */
// use photos
}
)
Depending on your confidence on your app architecture, you can also use unsafe transactions (dataStack.beginUnsafe()
) in conjunction with your own DispatchQueue
s.
@JohnEstropia Thank you very much. I got it.
Objective: allow a way to fetch objects in a way that can wait for completion of
Into<Entity>("...")
clause)