NotificationsView.swift
NotificationsViewに構造体(種別とチェック)の配列を追加
配列値をセットしたリストを追加
self.を忘れずに
[Product]-[Run]実行
左上のTabApplicationで戻って、Notificationsを選択。

NotificationsViewに構造体(種別とチェック)の配列を追加
struct NotificationsView: View {
var body: some View {
→
struct Fruit {
var kind: String
var checked: Bool
init(_ kind: String, checked: Bool) {
self.kind = kind
self.checked = checked
}
}
struct NotificationsView: View {
@State var fruits:[Fruit] = [
Fruit("やまぶどう", checked: true),
Fruit("からすうり", checked: true),
Fruit("へびいちご", checked: true),
Fruit("じゅずだま", checked: true)
]
var body: some View {
var body: some View {
Text("Hello, World!")
}
→
var body: some View {
VStack{
List {
ForEach(0 ..< fruits.count) { index in
HStack {
Text(self.fruits[index].kind)
Spacer()
Text(self.fruits[index].checked ? "通知あり" : "通知なし")
}
}
}
}
}
[Product]-[Run]実行
左上のTabApplicationで戻って、Notificationsを選択。
