April 2020
Beginner
316 pages
8h 20m
English
Even with implicit returns, we can add multiple views to our body without the need for the return keyboard. First, let's try adding another TextView and see what happens:
struct ContentView: View { var body: some View { Text("Hello World") Text("Learn SwiftUI") }}
Looking at the preceding example and trying to add another TextView underneath the existing one looks the right thing to do, but, unfortunately, if you duplicate the TextView in the current body, you'll be immediately presented with the following error:
Function declares an opaque return type, but has no return statements in its body from which to infer an underlying type
Basically, this means that body is expecting a single return type of View, but we are ...
Read now
Unlock full access