New developer, need help displaying on screen

brand new newbie developer to xcode. so im doing an api call and getting back data from a mysql database. in the xcode preview window im getting data, but i cant figure out how to tie it to the screen when going into the simulator. i have screen 1 that i want to click a button to go to screen 2 that displays the data. screen one (home screen) comes up okay. cant quite figure out what im doing wrong here. im thinking its either a class issue or something to do with view or something. not sure. ive tried looking at so many different videos and i cant seem to find my answer. Any help would be appreciated. thank you

View Controller:
import UIKit

let URL_TOURNAMENT_FETCH = "https://www.thesoftball.com/t2g_mobile_app/mobile_api.php"

class ViewController: UIViewController

{
override func viewDidLoad()

{
    super.viewDidLoad()
}


@IBAction func onEmailButtonPressed(_ sender: Any) 
{
    UIApplication.shared.open(URL(string: "mailto:[email]")! as URL, options: [:],completionHandler: nil)
}

@IBAction func ViewTournamentButton(_ sender: Any)

{

    // the following is a popup

    let alertController = UIAlertController(title: "Welcome to My First App", message: "Hello World", preferredStyle: UIAlertController.Style.alert)

            alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: nil))

            present(alertController, animated: true, completion: nil)           
}



@IBAction func account_button_pressed(_ sender: Any) 

{

    UIApplication.shared.open(URL(string: "https://www.thesoftball.com")! as URL, options: [:],completionHandler: nil)

}

}

ContentView (preview works in this):

import SwiftUI

struct ContentView: View {

@StateObject var viewModel = ViewModel()

var body: some View {

    NavigationView{

        List{

            ForEach(viewModel.courses,id: \.self) { tournament in

                HStack {
                    Image("")
                       .frame(width: 5, height: 120)
                       .background(Color.orange)
                    VStack {
                        Text(tournament.name).bold()
                        Text(tournament.dates)
                        Text(tournament.datee)
                        Text(tournament.location)
                    }
                }
                .padding(0)

            }

        }

        .navigationTitle("Tournaments")
        .onAppear(perform: viewModel.fetch)

    }
}

}

struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}

}

Swift forums are dedicated to the Swift language itself, not app development.

However, you can make a good start here: Apple/Developer/Documentation/SwiftUI

In addition to what @ibex10 said it seems you're mixing UIKit and SwiftUI. These are different frameworks to write your UI and while you can use both in a project it is not trivial for a beginner. SwiftUI is the new way to do apps, so I would recommend to follow the link @ibex10 already provided, and maybe specifically the tutorials: Introducing SwiftUI | Apple Developer Documentation. I've used them to give trainees a first glance into how an app is build and consider them quite helpful.

2 Likes

thank you guys. i can look. i had submitted a forum topic on the developer apple forum and nobody is responding. to be it seems like it should be something small. if it shows up in the preview but not in simulator, it is just not making the connections.

Another good resource for Swift development is Hacking with Swift.
They also have a forum to post questions https://www.hackingwithswift.com/forums

1 Like