Non-sendable type '(any URLSessionTaskDelegate)?' exiting actor-isolated context in call to non-isolated instance method 'data(from:delegate:)' cannot cross actor boundary
Please help, I am 1000% stuck on this issue in particular. Using strict asynchronous warnings, how can I make this work without warning? I can convert NetworkManager into a struct, but I prefer to keep it as an actor so that it is Sendable by default.
Post
Replies
Boosts
Views
Activity
Say I want to run a Task, with a for loop. Then have another Task with a for loop. And have these both run concurrently. Is there a way?
I tried doing this:
func stepAsyncStep(id: String, number: Int) async {
if number % 10000 == 0 {
print("chirp \(id) @ \(number)")
}
}
func somethingAsync(id: String) async {
for i in 0...100_000 {
await stepAsyncStep(id: id, number: i)
}
}
Task.detached {
print("task a begin")
await somethingAsync(id: "a")
print("task a end")
}
Task.detached {
print("task b begin")
await somethingAsync(id: "b")
print("task b end")
}
task a begin
chirp a @ 0
chirp a @ 10000
chirp a @ 20000
chirp a @ 30000
chirp a @ 40000
chirp a @ 50000
chirp a @ 60000
chirp a @ 70000
chirp a @ 80000
chirp a @ 90000
chirp a @ 100000
task a end
task b begin
chirp b @ 0
chirp b @ 10000
chirp b @ 20000
chirp b @ 30000
chirp b @ 40000
chirp b @ 50000
chirp b @ 60000
chirp b @ 70000
chirp b @ 80000
chirp b @ 90000
chirp b @ 100000
task b end
The only way I can make these run in parallel is to add sleeps into the loops. Is there any way to make then run concurrently without Task.sleep ?
I also tried a TaskGroup, this doesn't work either. Crying for help here.
Hello, thank you for your time.
I have run into a problem, which is effecting some of my customers. It seems like StoreKit is having trouble connecting to app store.
My code is this
func bounceStartSubscriptionPurchase() {
EventLogger.shared.logEvent(type: "Subscription", name: "StartSubscription")
isActive = true
isPurchasing = true
_isRestoring = false
if let oldRequest = productsRequest {
//If the old request is still alive, kill it
oldRequest.cancel()
oldRequest.delegate = nil
productsRequest = nil
}
StoreManager.postNotification(.purchaseBegin)
productsRequest = SKProductsRequest(productIdentifiers: ["hidden"])
productsRequest!.delegate = self
productsRequest!.start()
}
It works fine on my iPhone 5 with iOS 12. With my iPhone X on iOS 13.x, it is failing. Restore purchases seems to at least prompt for a login. The regular purchase will not even prompt for a login if I am not signed in (on sandbox or normal account) - it simply fails in less than 1 second.
Error is this:
Failed Error: Cannot connect to iTunes Store
Some printouts:
canMakePayments = true
does have product = true
request <SKProductsRequest: 0x281c3a300>
requestDidFinish
Update Transaction
Failed Error: Cannot connect to iTunes Store--- Transaction => Failed
Receipt Seconds Passed: 243.54082906246185