Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SwiftUI - NavigationView Error message - Argument passed to call that takes no arguments

Tags:

swift

swiftui

I am trying to implement a really basic NavigationView in SwiftUI. When I try the sample code that I have seen on other websites it generates an error message in Xcode. I am not sure why or how to fix this.

I have tried to clean the project, quit Xcode-Beta and restart it but that did not work.


struct ContentView : View {
    var body: some View {
        NavigationView {
            Text("This is a great app")
        }
    }
}

I thought the code above should work but the error I get says:

"Argument passed to call that takes no arguments."

Any ideas or suggestions?

like image 354
mikereining Avatar asked Jun 14 '19 16:06

mikereining


2 Answers

VStack can only take 10 argument. If more, there will be error, so you should make it nested.

from

VStack{

}

to

VStack{
    VStack{
    }
    VStack{
    }  
}
like image 168
koeru Avatar answered Sep 19 '22 15:09

koeru


I had this same error message too and figured out what I did wrong and then kind of felt like an idiot. Ha ha.

Take a look: Error

It took me a while to figure out that my struct was the same name as a previously defined struct VStack. Whoops!

So I'm wondering if you had a file in your project that did this too.

like image 39
Mark Moeykens Avatar answered Sep 21 '22 15:09

Mark Moeykens