proceeding case succeeded case error } let loadingState = Variable<LoadingState>(.idle) let saveData = Variable<SaveData?>(nil) func fetchSaveData(at index: Int) { SaveDataAPI(of: index).fetch { [weak self] (data: SaveData?) in if let data = data { self?.saveData.value = data self?.loadingState.value = .succeeded } else { self?.loadingState.value = .error } } } 10
case proceeding //!௨৴ঢ়ଶ͚ͩΛࣔ͢Enumʹ͠·͠ΐ͏ //"Ή͠Ζ Bool ͰࡁΉ } let loadingState = Variable<LoadingState>(.idle) let saveData = Variable<Result<Error, SaveData>?>(nil) //!௨৴ޙɺ݁Ռ(Error or SaveData)͕ඞͣೖΔ 13
let equipments: [E] //TableViewʹදࣔ͢ΔΞΠςϜͷϦετ init(character: Character) { self.equipments = character.items //Ωϟϥͷ͍࣋ͬͯΔΞΠςϜͷதͰɺ .flatMap { $0 as? E } // ͦͷͦ͏ͼछผͷͷΛTableViewʹදࣔ self.character = character } func select(equipment: E) { switch equipment { case let e as Weapon: performProcess(weapon: e) case let e as Armor: performProcess(armor: e) case let e as Shield: performProcess(shield: e) case let e as Helmet: performProcess(helmet: e) default: () } } // ܕϨϕϧͰ Ϳ͖ ͩͱಛఆͰ͖͍ͯΔʂʂ private func performProcess(weapon: Weapon) { ... } } 53