11
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[SwiftUI]"Extra argument in call"エラー

Last updated at Posted at 2020-05-09

SwiftUIの勉強中にハマったのでメモ。下記ソースコードでコンパイルエラーになりました。
原因はViewBuilderbuildBlockは10個までのためでした。

struct ContentView: View {
    var body: some View {
        VStack {
            Text("01")
            Text("02")
            Text("03")
            Text("04")
            Text("05")
            Text("06")
            Text("07")
            Text("08")
            Text("09")
            Text("10")
            Text("11")
        }
    }
}

10個以上の場合は、Groupを使う事で解消しました。

struct ContentView: View {
    var body: some View {
        VStack {
            Group {
                Text("01")
                Text("02")
                Text("03")
                Text("04")
                Text("05")
                Text("06")
                Text("07")
                Text("08")
                Text("09")
                Text("10")
            }
            Group {
                Text("11")
            }
        }
    }
}
11
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?