Let the code speak for itself:
final class Piece: UIView {
var picName: String
var column: Int
var row: Int
override var description: String {
return "picname: \(picName); column: \(column); row: \(row)" // error
}
init(picName: String, column: Int, row: Int) {
self.picName = picName
self.column = column
self.row = row
super.init(frame: .zero)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
This code, which has worked since Swift 1, is now illegal in Swift 6, evidently because description, believe it or not, is not main actor-isolated:
Main actor-isolated property 'picName' can not be referenced from a nonisolated context (and so on)
How am I supposed to work around this?
EDIT: One workaround is to declare picName, column, and row as constants, with let instead of var. But that doesn't necessarily do me any good, and in any case I still don't understand why that would make a difference, so this discovery just makes the mystery deeper.
CustomStringConvertibleto the main actor. See stackoverflow.com/q/79674589/1271826 for info on idiosyncrasies with backward support forprintfor macOS/iOS/etc prior to 26.