Thanks a lot Claude31!
Above all thanks for your patience in explaining me - I admit to have started just few weeks ago to develop in SwiftUI so I'm conscious of my limits.
Here the code for the Rosa structure:
import Foundation
struct Rosa: Identifiable, Codable, Hashable, Equatable {
var id = UUID()
let stagione: String
let nomeGiocatore: String
let cognomeGiocatore: String
let nascitaGiocatore: String
let etàGiocatore: Int
let ruoloGiocatore: String
init(stagione: String, nomeGiocatore: String, cognomeGiocatore: String, nascitaGiocatore: String, etàGiocatore: Int, ruoloGiocatore: String) {
self.stagione = stagione
self.nomeGiocatore = nomeGiocatore
self.cognomeGiocatore = cognomeGiocatore
self.nascitaGiocatore = nascitaGiocatore
self.etàGiocatore = etàGiocatore
self.ruoloGiocatore = ruoloGiocatore
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd-MM-yyyy"
guard let birthDate = dateFormatter.date(from: nascitaGiocatore) else { return}
let currentYear = Calendar.current.component(.year, from: Date())
let birthYear = Calendar.current.component(.year, from: birthDate)
_ = currentYear - birthYear
}
static func testRosa() -> [Rosa] {
return [Rosa(stagione: "2023/2024", nomeGiocatore: "Matt", cognomeGiocatore: "Bar", nascitaGiocatore: "31-03-2000", etàGiocatore: 24, ruoloGiocatore: "Portiere"),
Rosa(stagione: "2023/2024", nomeGiocatore: "Fabio", cognomeGiocatore: "Bel", nascitaGiocatore: "30-11-1982", etàGiocatore: 41, ruoloGiocatore: "Difensore"),
Rosa(stagione: "2023/2024", nomeGiocatore: "Ale", cognomeGiocatore: "Nev", nascitaGiocatore: "23-04-2001", etàGiocatore: 23, ruoloGiocatore: "Attaccante"),
Rosa(stagione: "2022/2023", nomeGiocatore: "Matte", cognomeGiocatore: "Repe", nascitaGiocatore: "28-02-1999", etàGiocatore: 25, ruoloGiocatore: "Centrocampista")]
}
}
I have then indeed applied all your suggestions, even if the second one "Using the structure name (Rosa) as the argument of the closure is incorrect." is not clear to me. Would you be so kind to help me in understanding it?
Thanks,
A.