dataStack.perform(asynchronous: { (transaction) in
let objects = try transaction.fetchAll()
backgroundQueue.async {
URLSession.shared.dataTask(){
dataStack.perform(asynchronous: {(transaction) in
let item = try transaction.fetchOne()
// update item fetched object
}, completion: { _ in
})
}
}
}, completion: { (result) in {
})
Thanks for your help.
Originally created by @seanliu1 on GitHub (Jan 9, 2020).
We are experiencing this crash, would love your help to figure out what's going on.
```
Crashed: Updater
0 libobjc.A.dylib 0x182fb0fb0 objc_msgSend + 16
1 CoreData 0x187d10dd8 _PFFaultHandlerLookupRow + 1064
2 CoreData 0x187d12ac4 _PF_FulfillDeferredFault + 248
3 CoreData 0x187d26d38 _pvfk_header + 120
4 CoreData 0x187d26b78 _sharedIMPL_pvfk_core_q + 32
5 CoreData 0x187d26e40 __generateAccessor_block_invoke + 28
```
Here is what we are doing
```
dataStack.perform(asynchronous: { (transaction) in
let objects = try transaction.fetchAll()
backgroundQueue.async {
URLSession.shared.dataTask(){
dataStack.perform(asynchronous: {(transaction) in
let item = try transaction.fetchOne()
// update item fetched object
}, completion: { _ in
})
}
}
}, completion: { (result) in {
})
```
Thanks for your help.
adam
added the question label 2025-12-29 15:28:28 +01:00
Which line are you getting the exception from? Try to add an Exception Breakpoint and let me know which line it stops
@JohnEstropia commented on GitHub (Jan 9, 2020):
Which line are you getting the exception from? Try to add an Exception Breakpoint and let me know which line it stops
Should we access fetched object in different thread?
@seanliu1 commented on GitHub (Jan 9, 2020):
At least xcode stops/ crashes at the line when we use fetched objects to construct network request.
```
let objects = try transaction.fetchAll()
backgroundQueue.async {
// construct url request (crashed here)
URLSession.shared.dataTask(){
```
Should we access fetched object in different thread?
I'm guessing you omitted some code here, but you can't use transaction objects outside the transaction closure. You can't dispatch them out into another queue.
My suggestion is to use the object values immediately to create the request, and pass the request to the background instead.
@JohnEstropia commented on GitHub (Jan 10, 2020):
I'm guessing you omitted some code here, but you can't use transaction objects outside the transaction closure. You can't dispatch them out into another queue.
My suggestion is to use the object values immediately to create the request, and pass the request to the background instead.
```swift
dataStack.perform(
asynchronous: { (transaction) -> URLRequest in
let objects = try transaction.fetchAll()
let request: URLRequest = // ...
return request
},
completion: { (result) in {
guard case .success(let request) = result else {
return
}
backgroundQueue.async {
URLSession.shared.dataTask(request) { response in
// ...
dataStack.perform(
asynchronous: { (transaction) in
let item = try transaction.fetchOne()
// update item fetched object
},
completion: { _ in }
)
}
}
}
)
```
Another way is to use
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 @seanliu1 on GitHub (Jan 9, 2020).
We are experiencing this crash, would love your help to figure out what's going on.
Here is what we are doing
Thanks for your help.
@JohnEstropia commented on GitHub (Jan 9, 2020):
Which line are you getting the exception from? Try to add an Exception Breakpoint and let me know which line it stops
@seanliu1 commented on GitHub (Jan 9, 2020):
At least xcode stops/ crashes at the line when we use fetched objects to construct network request.
Should we access fetched object in different thread?
@JohnEstropia commented on GitHub (Jan 10, 2020):
I'm guessing you omitted some code here, but you can't use transaction objects outside the transaction closure. You can't dispatch them out into another queue.
My suggestion is to use the object values immediately to create the request, and pass the request to the background instead.
Another way is to use
@seanliu1 commented on GitHub (Jan 19, 2020):
thanks