में नहीं मिला है कृपया कोई मेरी मदद कर सकता है।एनम केस स्विच प्रकार
मैं public enum
public enum OfferViewRow {
case Candidates
case Expiration
case Description
case Timing
case Money
case Payment
}
निम्नलिखित और निम्नलिखित mutableProperty:
private let rows = MutableProperty<[OfferViewRow]>([OfferViewRow]())
मेरी init फ़ाइल में मैं कुछ 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]
}
}
लेकिन अब समस्या, जब मैं अपनी पंक्तियों के अंदर अपने enum के मूल्य प्राप्त करने की कोशिश करता हूं 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
}
}
यह एक त्रुटि थ्रो: let row = rows.value[indexPath.row]
और हर पर बयान स्विच लाइन पर Enum case 'some' not found in type 'OfferViewRow
फेंक देता है: Enum case 'Candidates' not found in type '<<Error type>>
किसी ने मुझे इस के साथ मदद कर सकते हैं?
क्या आप 'सार्वजनिक enum ऑफरViewRow: Int' को enum –
की घोषणा के रूप में आज़मा सकते हैं, मदद भी नहीं की! – Steaphann
स्थिर 'पंक्ति' का प्रकार क्या है? –