Answer the question
In order to leave comments, you need to log in
How to store arrays in @AppStorage swift?
How to store arrays in @AppStorage swift?
struct Odd: Identifiable {
var id: String = UUID().uuidString
var title: String
var completed: Bool
}
var oddData = [
Odd(title: "1", completed: false),
Odd(title: "2", completed: true),
Odd(title: "3", completed: false)
]
@State private var textFieldData = ""
@State private var odds = oddData
TextField("Odd name: ", text: $textFieldData )
.textFieldStyle(RoundedBorderTextFieldStyle())
Button(action: {
odds.append(Odd(title: "\(textFieldData)", completed: false))
}, label:{
Image(systemName: "plus.circle.fill")
.resizable()
.frame(width: 25, height: 25)
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question