【发布时间】:2016-02-22 06:16:20
【问题描述】:
有人可以帮我解决这个问题吗?
我有以下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]
}
}
但是现在的问题是,当我尝试在行中获取枚举的值时,它会引发错误。请看下面的代码。
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作为枚举声明 -
没救了,也试过了!
-
常量
row的类型是什么?
标签: ios swift enums swift2 reactive-cocoa