import SwiftUI struct SwapperView: TabContent { static var title = "Swap" static var image = "rectangle.2.swap" @State var sw = Swapper(a: "Apfel", b: "Banana") @State var a = "Apfel" @State var b = "Banane" func tausche(){ let tmp = a a = b b = tmp } var body: some View { VStack { Text("Vorher \(a) <-> \(b)") Button("Show Alert") { print("Hello, World!") tausche() sw.tausche() } Text("Swapping \(sw.a) <-> \(sw.b)") } } } struct Swapper { var a: T var b: T mutating func tausche(){ let tmp = a a = b b = tmp } } #Preview { SwapperView() }