Sunday, November 27, 2022
HomeIOS Developmentios - Why does the Sendable kind is just not checked when...

ios – Why does the Sendable kind is just not checked when defining the generic struct of Sendable sorts


I am going via
https://developer.apple.com/movies/play/wwdc2021/10133/
video, and I’ve created exmple to check Sendable kind.
Why does this piece of code nod elevate and compiler error?

class Creator {
    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 okay = Pair<Int, Creator>(first: 5, second: Creator())

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

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments