普段はAndroidのエンジニアをしてますが、SwiftUIを触っていたところ、initが必要なSwiftUIを作成していたところBindingが初期化されてないことにハマったので記載しておこうと思います。
TimeView.swift
@Binding var dateTextTime: String
@Binding var nowDate: Date
init(dateTextTime: Binding<String>,nowDate: Binding<Date>) {
self._dateTextTime = dateTextTime
self._nowDate = nowDate
}
引数の型は Binding<String>
と、Binding<Date>
です。
名前の前に_
を付けることが必要となります。
全然分からず悩みました。
普段Android開発をしてますが昔UI作るのに苦戦していたので、SwiftUiでUIを簡単に作れるようになったので、iOSの開発もやっていこうと思います。