初心者プログラミング日記 SwiftUI③
WWDC20 Introduction to SwiftUI続き(42分42秒あたりから)
//
// SandwichStore.swift
// Landmarks
//
//
import Foundation
//サンドイッチを含む変更可能なオブジェクト
//テスト用に単集合インスタンスも用意
//私たちがオブジェクトを変更する時にはSwiftUIへの指示が必要なので、
//変更するオブジェクトにはObseravableObjectを継承させる
class SandwichStore: {
var sandwiches: [Sandwich]
init(sandwiches: [Sandwich] = []){
self.sandwiches = sandwiches
}
}
let testStore = SandwichStore(sandwiches: testData)