У меня есть 9 просмотров с 9 признаками распознавания жестов, которые выполняют очень похожие задачи. Я сгребал свой мозг, чтобы подумать о более красноречивом способе написания этого, но ничего не смог придумать. Любая помощь будет очень оценена!Самый красноречивый способ написания группы распознавателей жестов, которые делают похожие вещи
func flipToBack(){
let matrix = Animations.HotSpotNumber(rawValue: currentHotSpot)
guard let dict = matrix?.instructions else {return}
flipLayerSecondPhaseWithInstructions(dict, layer: frontView.layer, directionOfTransformation: "towardsBackSide")
}
func flipToFront(){
let matrix = Animations.HotSpotNumber(rawValue: currentHotSpot)
guard let dict = matrix?.instructions else {return}
flipLayerSecondPhaseWithInstructions(dict, layer: frontView.layer, directionOfTransformation: "towardsFrontSide")
}
func handleBackSideTap(){
let animation = Animations.HotSpotNumber(rawValue: currentHotSpot)
guard let dict = animation?.instructions else {return}
flipLayerFirstPhaseWithInstructions(dict, layer: frontView.layer, directionOfTransformation: "towardsFrontSide")
}
func handleHotSpotOneTap(){
let dict = Animations.HotSpotNumber.One.instructions
currentHotSpot = 1
flipLayerFirstPhaseWithInstructions(dict, layer: frontView.layer, directionOfTransformation: "towardsBackSide")
}
func handleHotSpotTwoTap(){
let dict = Animations.HotSpotNumber.Two.instructions
currentHotSpot = 2
flipLayerFirstPhaseWithInstructions(dict, layer: frontView.layer, directionOfTransformation: "towardsBackSide")
}
func handleHotSpotThreeTap(){
let dict = Animations.HotSpotNumber.Three.instructions
currentHotSpot = 3
flipLayerFirstPhaseWithInstructions(dict, layer: frontView.layer, directionOfTransformation: "towardsBackSide")
}
func handleHotSpotFourTap(){
let dict = Animations.HotSpotNumber.Four.instructions
currentHotSpot = 4
flipLayerFirstPhaseWithInstructions(dict, layer: frontView.layer, directionOfTransformation: "towardsBackSide")
}
func handleHotSpotSixTap(){
let dict = Animations.HotSpotNumber.Six.instructions
currentHotSpot = 6
flipLayerFirstPhaseWithInstructions(dict, layer: frontView.layer, directionOfTransformation: "towardsBackSide")
}
func handleHotSpotSevenTap(){
let dict = Animations.HotSpotNumber.Seven.instructions
currentHotSpot = 7
flipLayerFirstPhaseWithInstructions(dict, layer: frontView.layer, directionOfTransformation: "towardsBackSide")
}
func handleHotSpotEightTap(){
let dict = Animations.HotSpotNumber.Eight.instructions
currentHotSpot = 8
flipLayerFirstPhaseWithInstructions(dict, layer: frontView.layer, directionOfTransformation: "towardsBackSide")
}
func handleHotSpotNineTap(){
let dict = Animations.HotSpotNumber.Nine.instructions
currentHotSpot = 9
flipLayerFirstPhaseWithInstructions(dict, layer: frontView.layer, directionOfTransformation: "towardsBackSide")
}
Эти жесткокодированные значения '.One' ...' .Nine' действительно должны быть индексами 'Int' в массиве – Alexander
Я не уверен, как это сделать в перечислении. У вас есть пример? – aBikis