Код: Выделить всё
Generic parameter 'V' could not be inferred
Вот фрагмент кода, ошибка отображается в разделе («Разделы» ") Линия.
Код: Выделить всё
Section("Sections") {
TextField("Add a new Section", text: $sectionName)
.padding([.top, .bottom], 10)
Button(action: {
tapas.tapasSections.append(sectionName)
sectionName = ""
}, label: {
Text("Add Section")
})
List(tapas.tapasSections) { name in
Text("\(name)")
}
}
Код: Выделить всё
import Foundation
import SwiftData
@Model
class Tapas {
var name: String
/// Time Frame of the Tapas
var currentDay: Int
var lengthInDays: Int = 21
var lastDay: Date
var startDay: Date = Date()
var intention: String
var intentionEvoked: Bool = false
var rules: String = ""
var supportTime: [Date] = []
var tapasSections: [String] = []
var recuperated: Bool
var tapasType: String
var isActive: String
var recupType: String /// NoRecoup, TimedRecoup, UnlimitedRecoup for No recouperations, Recouperations before Last Day, And even after
var resetTime: Date
var color: String
/// Adding a relation to TapasAsana, as one Tapas has many Asanas
@Relationship(deleteRule: .cascade) var asanas = [TapasAsana]()
init(name: String = "", intention: String = "", currentDay: Int = 1, lengthInDays: Int = 49, lastDay: Date = .now, recuperated: Bool = false, tapasType: String = "hatha", isActive: String = "dormant", recupType: String = "NoRecoup", resetTime: Date = .now, color: String = "blue") {
self.name = name
self.intention = intention
self.currentDay = currentDay
self.lengthInDays = lengthInDays
self.lastDay = lastDay
self.recuperated = recuperated
self.tapasType = tapasType
self.isActive = isActive
self.recupType = recupType
self.resetTime = resetTime
self.color = color
}
}
Подробнее здесь: https://stackoverflow.com/questions/793 ... ome-arrays
Мобильная версия