Attrubute can only be applied to types not declarations

Error: "Attrubute can only be applied to types not declarations" on line 2 : @unchecked


@unchecked
enum ReminderRow : Hashable, Sendable {
    case date
    case notes
    case time
    case title
    
    var imageName : String? {
        switch self {
            case .date: return "calendar.circle"
            case .notes: return "square.and.pencil"
            case .time: return "clock"
            default : return nil
        }
    }
    
    var image : UIImage? {
        guard let imageName else { return nil }
        let configuration = UIImage.SymbolConfiguration(textStyle: .headline)
        return UIImage(systemName: imageName, withConfiguration: configuration)
    }
    
    var textStyle : UIFont.TextStyle {
        switch self {
        case .title : return .headline
        default : return .subheadline
        }
    }
}
Answered by DTS Engineer in 862949022

If your goal is to make ReminderRow unchecked sendable, the syntax to use is:

enum ReminderRow : Hashable, @unchecked Sendable {
    …
}

Having said that, I don’t think this makes a lot of sense for a simple enum. I put ReminderRow into a simple test program and it seems to be sendable by default. What problem are you trying to solve by adding @unchecked?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

If your goal is to make ReminderRow unchecked sendable, the syntax to use is:

enum ReminderRow : Hashable, @unchecked Sendable {
    …
}

Having said that, I don’t think this makes a lot of sense for a simple enum. I put ReminderRow into a simple test program and it seems to be sendable by default. What problem are you trying to solve by adding @unchecked?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Attrubute can only be applied to types not declarations
 
 
Q