import SwiftUI
struct ContentView: View {
var model = ViewModelPhone()
@State var reachable = "No"
@State var Message = ""
@State var GolfCount :Int = 0
var body: some View {
VStack{
Text("Reachable \(reachable)")
Button(action: {
if self.model.session.isReachable{
self.reachable = "Yes"
}
else{
self.reachable = "No"
}
}) {
Text("Update")
}
//mesage input
TextField("Input your message", text: $Message)
.padding(100)
Button(action: {
//message sending
self.model.session.sendMessage(["message" : self.Message], replyHandler: nil) { (error) in
print(error.localizedDescription)
}
}) {
Text("Send")
} //golf Counting
Button(action: {
GolfCount += 1
})
{
Text("Schläge")
Text(String(GolfCount))
}}}}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
!Image of the both devices|180x499](upload://amrzKcHGj9uCgQGd3mKfkltriYw.jpeg)
the sending function is working, and is displayed on the watch, the counter is counting, and now I am wondering how to get the Int value to the watch, while being a “working” variable any advice?