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()
}
}