Sunday, December 4, 2022
HomeiOS Developmentios - Why does the Sendable kind will not be checked when...

ios – Why does the Sendable kind will not be checked when defining the generic struct of Sendable sorts

I am going by way of
video, and I’ve created exmple to check Sendable kind.
Why does this piece of code nod increase and compiler error?

class Writer {
    var firstName: String = ""
    var secondName: String = ""
    var notifCenter: NotificationCenter = NotificationCenter.default

struct Pair<T, U> the place T: Sendable, U: Sendable {
    var first: T
    var second: U

var ok = Pair<Int, Writer>(first: 5, second: Writer())

I’ve deliberately added notifCenter saved property to the category of Writer to not permit for some compiler magic. Writer is clearly not the Sendable kind but the compile does not appear to have an issue with it.



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments