我需要进行计算，但只得到字符串。我应该怎么算？

``````import SwiftUI

enum CalcButtons: String {

case zero, one, two, three, four, five, six, seven, eight, nine
case equals, plus, minus, multiply, divide, decimal
case ac, minusPlus, percent, rootExtraction, factorial, tenInExponentiation, numberInExponentiation, deleteOneDigit

var title: String {
switch self {
case .zero: return "0"
case .one: return "1"
case .two: return "2"
case .three: return "3"
case .four: return "4"
case .five: return "5"
case .six: return "6"
case .seven: return "7"
case .eight: return "8"
case .nine: return "9"
case .minusPlus: return "+/-"
case .percent: return "%"
case .divide: return "÷"
case .multiply: return "x"
case .plus: return "+"
case .minus: return "-"
case .equals: return "="
case .decimal: return "."
case .deleteOneDigit: return "←"
case .rootExtraction: return "√x"
case .factorial: return "X!"
case .tenInExponentiation: return "10ª"
case .numberInExponentiation: return "X^10"
default:
return "AC"
}
}

var backgroundButtonsColor: Color {
switch self {
case .zero, .one, .two, .three,.four, .five, .six, .seven, .eight, .nine, .decimal:
return Color(.darkGray)
case .ac, .minusPlus, .percent, .rootExtraction, .factorial, .tenInExponentiation, .numberInExponentiation, .deleteOneDigit:
return Color(.lightGray)
default:
return .orange
}
}

}

class DisplayingActions: ObservableObject {

@Published var display = ""

func displayAction(calculatorButtons: CalcButtons){

self.display = self.display + calculatorButtons.title

switch calculatorButtons {
case .ac:
return self.display = ""
case .decimal:
if self.display == calculatorButtons.title && calculatorButtons.title != "."{
return self.display = self.display + "."
} else { return
self.display = "0."

}
default:
break
}

}

}

struct ContentView: View {

@EnvironmentObject var actions: DisplayingActions

let buttons: [[CalcButtons]] = [
[.ac, .minusPlus, .percent, .divide, .deleteOneDigit],
[.seven, .eight, .nine, .multiply, .rootExtraction],
[.four, .five, .six, .minus, .numberInExponentiation],
[.one, .two, .three, .plus, .tenInExponentiation],
[.zero, .decimal, .equals, .factorial]]

var body: some View {

ZStack (alignment: .bottom) {
Color.black.edgesIgnoringSafeArea(.all)

VStack(spacing: 3) {

HStack {
Spacer()
Text(actions.display)
.foregroundColor(.white)
.font(.system(size: 62))

ForEach(buttons, id: \.self) { row in
HStack (spacing: 3) {
ForEach(row, id: \.self) {button in
CalculatorButtonsView(button: button)

}

}
}
}
}
``````

}

``````struct CalculatorButtonsView: View {

var button: CalcButtons

@EnvironmentObject var actions: DisplayingActions

var body: some View{
Button(action: {

self.actions.displayAction(calculatorButtons: self.button)
}) {
Text(button.title)
.font(.system(size: 30))
.frame(width: buttonWidth(button: button), height: (UIScreen.main.bounds.width - 5 * 3 ) / 5)
.foregroundColor(.white)
.background(button.backgroundButtonsColor)

}
}
private  func buttonWidth(button: CalcButtons) -> CGFloat {

if button == .zero {
return (UIScreen.main.bounds.width - 4 * 3 ) / 4 * 1.6
}
return (UIScreen.main.bounds.width - 5 * 3 ) / 5
}
}

struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView().environmentObject(DisplayingActions())
}
``````

}