Вы пытаетесь получить доступ к rawValue
объекта priority
.ОДНАКО, что priority
на самом деле Int
.
Если вы измените строку let indexPath = IndexPath(row: index, section: priority.rawValue)
на
let indexPath = IndexPath(row: index, section: currentList.priority.rawValue)
, она, вероятно, будет работать, предполагая, что currentList
с TodoList
является перечислением.
Вернемся к основам перечисления в Swift.
Если, например, у нас есть перечисление с именем PhoneType
, которое имеет тип rawValue Int
:
enum PhoneType: Int {
case iPhone5s = 568
case iPhone8 = 667
case iPhone8Plus = 736
case iPhoneX = 812
}
тогда мы можем создать экземпляр PhoneType
, передав rawValue Int
, и использовать перечисление в выражениях switch или if-else, например:
let screenHeight = Int(UIScreen.main.bounds.height)
if let type = PhoneType(rawValue: screenHeight) {
switch type {
case .iPhone5s: print("we are using iPhone5s and similar phones like SE/5C/5")
case .iPhone8: print("we are using iPhone 8 and similar phones")
case .iPhone8Plus: print("we are using iPhone 8plus or 7plus or 6 plus.")
default: print("and so on...")
}
}
Надеюсьэто помогает.