Learn Courses My Dashboard

Converting to SwiftUI

I built a drink dispenser for the office. You have to answer quiz questions to earn credits for a drink. It dispenses via bluetooth and retrieves JSON questions from a remote server. The current functioning app was built on UIKit and is based on the CWC quiz app from the UIKit fundamentals section. But I want to rebuild it in SwiftUI.

I have no problems fetching the JSON data. All the questions are there if I print them from that page . I can also make a rough draft question UI as long as I use dummy data supplied within the view. But I can’t successfully get the JSON from the ViewModel to the View.

I’ve tried all the various property wrappers, different inits, changing the model to a function and doing the “onAppear” route and all have failed. I have a feeling the error is simple, but I’m stuck. Thank you in advance for help.

![Screen Shot 2021-04-08 at 9.34.19 AM|248x273]
(upload://zeNZOQToQBR2Mr7fCM8Kd5alsZ1.png)

Chris Ching has some tutorials on CWC+ that will get you familiar with what you need to do in SwiftUI. Check out his tutorials here: learn.codewithchris.com

OK. If that’s the answer I can expect then please cancel my subscription

If you are already a CWC member then have you gone through the SwiftUI modules that deal with the MVVM structure because that is important to get to grips with.

I see that you have your NetworkManager configured as the ObservableObject. Is that effectively the ViewModel in this case or do you have a separate ViewModel configured to support ContentView?