Questions tagged [sendable]
10 questions
3
votes
1 answer
CoreData and Swift's Actor and Sendable
I am trying to understand Swift's Actors, but failed. I am playing around with the following example.
I want to setup a LocalStore that uses an NSPersistentContainer.
The struct LocalStore should be used by a StoreManager declared as
actor…

Reinhard Männer
- 14,022
- 5
- 54
- 116
2
votes
1 answer
Foundation.Date does not conform to Sendable. Now what?
The following presents a warning in Xcode 14 complete concurrency checking mode.
struct Article: Sendable {
let title: String
let date: Date // non sendable type warning
}
This warning will become an error in Swift 6.
How do we handle this?

bobby123uk
- 892
- 4
- 17
2
votes
1 answer
Swift Actors and old dependencies
I am learning swift and trying to use the new concurrency features introduced by Swift 5.5, and to make my code conform to the new requirements that will eventually be introduced by Swift 6.
My project uses SwiftUI & MVVM as well as some…

lmag
- 21
- 2
2
votes
1 answer
Capture of 'self' in a `@Sendable` closure
My app uses the following view controller with an IBAction.
When the action is triggered by some button, the button is disabled, and some background processing is started.
When background processing is finished, the button is enabled again, which…

Reinhard Männer
- 14,022
- 5
- 54
- 116
0
votes
1 answer
Sendability of function types in property does not match requirement in protocol
I am trying to add a protocol which has all the attributes and functions of a Process but I see a warning with terminationHandler.
I was hoping not to see this warning since @Sendable is already added to terminationHandler.
protocol ProcessProtocol…

Siddhant Mishra
- 346
- 1
- 15
0
votes
1 answer
Why are non-sendable properties mutable from Tasks in Swift
A lot of online resources say non-final classes are not Sendable by default. That means classes and their properties are not thread-safe. So why is this code not raising an error:
class Counter {
var count = 0
func increment() {
…

rayaantaneja
- 1,182
- 7
- 18
0
votes
1 answer
How can i pass sortDescriptors into CloudKitUtility.fetch() as parameter in @MainActor environment?
Non-sendable type '[NSSortDescriptor]?' exiting main actor-isolated context in call to non-isolated static method 'fetch(recordType:predicate:sortDescriptions:resultsLimit:)' cannot cross actor boundary
Following code will report this error with…

foolbear
- 726
- 1
- 7
- 19
0
votes
1 answer
How to make non-sendable type usable in Sendable context?
I have such code
public func webView(
_ webView: WKWebView,
didReceive challenge: URLAuthenticationChallenge,
completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void
) {
…

Michał Ziobro
- 10,759
- 11
- 88
- 143
0
votes
0 answers
SWIFTUI refreshable viewModifier
For SWIFTUI i have created a ViewModifier to use the refreshable(action) view modifier available under iOS15.
with this modifier I don't have to embed my all view in availability check.
It's seems to work properly, but I'm not confortable with the…

swordse
- 1
- 2
0
votes
1 answer
Can I call an actor's function from a @Sendable sync function?
I'm not sure if this is even possible, but I thought I should ask anyway!
I have a "UserDefaults" client and "live"/"mock" implementations of its interface (taken from a TCA example, but that shouldn't matter).
I want to have the mock implementation…

phi
- 10,634
- 6
- 53
- 88