有人可以幫助我這個。枚舉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
常量「行」的類型是什麼? –