|
Hi - I have a simple view with one text block that is references variable The variable is stored within my class and is @Published - see below..... See at bottom of class "func receive" When the network message is received I see it printed in the debug I then update the variable to match the message I then print the updated variable so I can see it has been changed But the text in my view does not change Any Ideas
|
|
The thing that occurs to me is that since the score property on the Two things need to happen for the published score to be sent to the view:
|
|
Hi @sbeitzel Thanks for your advice. I've tried to implement your solution but no joy. I'm not sure if I'm doing this correctly. At Top Of Class I Have...
then in the receive method I have...
|
|
Hmm, I think I didn't explain clearly. What I meant was, go back to the first code that you posted, and then change the implementation of the
If you're importing Foundation, you don't need to import Combine just to get DispatchQueue. And you don't need to provide your own |
|
Hi @sbeitzel Thanks for the explaination Unfortunately Still No Joy i can see from the debug that score is being updated but not reflected in the view Found loads of similar solutions online but none seem to work Will keep trying Current View
Current Class
|
|
SOLVED Firstly thanks to @sbeitzel for help with "main thread" etc As mentioned we still couldnt get the view to update. The solution was staring us in the face... In the "Connect" class we create a singleton instance when at the top we declare..
In the content view we create a second instance of Connect() when we declare...
SOLUTION -> Remove the redeclaration of Connect() in ContentView This will flag errors in the button code below but thats easy to fix Replace any mention of "communication" with "connect" |
SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.