You see, on one side we have missions that know crew member “armstrong” had the role “Commander”, but has no idea who “armstrong” is, and on the other side we have “Neil A. Armstrong” and a description of him, but no concept that he was the commander on Apollo 11.This is the problem we need to address as stated by Paul, so we already have an Astronaut struct
struct Astronaut: Codable, Identifiable {
let id: String
let name: String
let description: String
}
if let astronaut = astronauts[member.name]
if there was an a astronaut in the astronauts json file which we define as [String: Astronaut] here the String is the name of astronaut also acts as key of dictionary, in the mission.json if we get the name of astronaut and it is also in astronaut.json then fetch it as key and pass value to CrewMember , to be used later...
This is an attempt to find some commom field as in database, to connect both tables together , here this is the name of astronaut ...if let astronaut
is just checking if we can get a value from astronauts[member.name]
, as member.name will act as key , if so give me CrewMember else throw an error