Ai đó có thể giúp tôi với điều này.Chuyển đổi trường hợp không được tìm thấy trong loại
Tôi có sau public enum
public enum OfferViewRow {
case Candidates
case Expiration
case Description
case Timing
case Money
case Payment
}
Và mutableProperty sau:
private let rows = MutableProperty<[OfferViewRow]>([OfferViewRow]())
Trong file init của tôi, tôi sử dụng một số reactiveCocoa thiết MutableProperty tôi:
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]
}
}
Nhưng bây giờ vấn đề, khi tôi cố gắng để có được giá trị của enum của tôi bên trong hàng của tôi t ném lỗi. Vui lòng xem mã bên dưới.
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
}
}
Nó ném một lỗi: Enum case 'some' not found in type 'OfferViewRow
trên dòng let row = rows.value[indexPath.row]
Và trên tất cả các chuyển đổi báo cáo nó ném: Enum case 'Candidates' not found in type '<<Error type>>
Có thể ai đó giúp tôi với điều này?
bạn có thể thử 'phiếu mua hàng công khaiXemLàm thế nào: Int' như tuyên bố của enum –
Không được trợ giúp, cũng đã thử! – Steaphann
Loại 'hằng số' liên tục là gì? –