I can't get past "hello world" when I run my app through the simulator

I'm trying to figure out how do I get past "hello World" when I run my app through the simulator, it says build successful but "Hello World" is as far as I could get when I run the app through the simulator, any suggestions??

Replies

What do you expect ?


What is the code of your app ?


The first suggestion is that you show your code.

i expect it show "hello world" and then get off the screen so i could use the app but it doesnt do that, it just stays like that


import SwiftUI



struct ContentView: View {

var body: some View {

Text("Hello World")


}

}

#if Debug

struct ContentView_Previews: PreviewProvider {

static var previews: some View {

ContentView()

}


}#endif

So, that's SwiftUI, you should post your question in SwiftUI part of the forum.


then get off the screen so i could use the app

Use to do what ?

Your app does exactly what you asked for: Say Hello.


If there is nothing more in the code, it will not do anything more !


Do you follow a tutorial to start learning ?


As an example, here is an app which will do just a little more :


import SwiftUI

struct ContentView: View {
    @State var destContent = "Some text to pass"
    var body: some View {
        NavigationView {
           NavigationLink(destination: DestView(passed: self.$destContent)) {
              Text("Press on me")
           }.buttonStyle(PlainButtonStyle())
        }
    }
}

struct DestView: View {
    @Binding var passed: String
    var body: some View {
        Text("Hello, World! \(passed)")
    }
}

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



Note:

If you want to run the app from the Simulator screen:

- quit the app the usual way (press button on iPhone at bottom, or swipe the screen up to quit the app)

- then you will see your app in the list of iPhone app

- doucle click to launch

yeah i do follow a tutorial to start learning but the guys version of xcode is an earlier one which doesnt have content view and he couldn't understand completly so i am here, i'm guessin i need to write a code that'll get me off that screen and on to the main screen

Did you read my answer ?


- Does the note answer your question ?

- did you test the code ?


i expect it show "hello world" and then get off the screen so i could use the app but it doesnt do that, it just stays like that

Please explain clearly what you do, what you expect.

get off the screen: what do you mean here ?

it doesn't do that: when you do what ? Click somewhere ? Something else.

i did read your answer but it didnt work i got multiple errors... I need to be able to get to the other screens but i'm not able to do that i'm stuck at hello world

i got multiple errors...

What errors ? This is code I tested that works here.


As long as you do not explain in a comprehensible way what you mean by " i'm stuck at hello world", there is little to do for you.

{ NavigationLink(destination: DestView(passed: self.$destContent)) {

Use of unresolved identifier "DestView"

DestView is defined by:

struct DestView: View { 
    @Binding var passed: String 
    var body: some View { 
        Text("Hello, World! \(passed)") 
    } 
}
Even i am facing the same problem , can someone help me. My code is on another swift page but the main page opens up as Contentview.