有人可以帮助我这个。枚举case开关找不到类型
我有以下public enum
public enum OfferViewRow {
case Candidates
case Expiration
case Description
case Timing
case Money
case Payment
}
而下面mutableProperty:
private let rows = MutableProperty<[OfferViewRow]>([OfferViewRow]())
在我的初始化文件我用一些reactiveCocoa设置我MutableProperty:
rows <~ application.producer
.map { response in
if response?.application.status == .Applied {
return [.Candidates, .Description, .Timing, .Money, .Payment]
} else {
return [.Candidates, .Expiration, .Description, .Timing, .Money, .Payment]
}
}
但现在这个问题,当我尝试在我的行内获得枚举值时t会抛出错误。请看下面的代码。
func cellViewModelForRowAtIndexPath(indexPath: NSIndexPath) -> ViewModel {
guard
let row = rows.value[indexPath.row],
let response = self.application.value
else {
fatalError("")
}
switch row {
case .Candidates:
// Do something
case .Expiration:
// Do something
case .Description:
// Do something
case .Timing:
// Do something
case .Money:
// Do something
case .Payment:
// Do something
}
}
它抛出一个错误:Enum case 'some' not found in type 'OfferViewRow
上线let row = rows.value[indexPath.row]
而且在每一个switch语句,它抛出:Enum case 'Candidates' not found in type '<<Error type>>
有人可以帮助我?
你可以试试'public enum OfferViewRow:Int'作为枚举的声明 –
不用帮助,也试过了! – Steaphann
常量“行”的类型是什么? –