Home>

As the title says.
I want to display the text acquired by API in collectionViewController
UsingCodable, Json data obtained by API is formatted.
I would like to get all the nested data in it (image of for statement), but I would appreciate it if you could teach me how to draw the code.

I tried to write as follows, buttag [0] .namecan only get one, sonameintagI want to be able to get all code>.

store! [indexPath.row] .tag [0] .name
truct Store: Codable {
    let id: Int
    let name: String
    let location: String
    let price: String
    let open_time: String
    let closed_day: String
    let categories: [categories]
    let tags: [tags]
    struct categories: Codable {
        let id: Int
        let name: String
    }
    struct tags: Codable {
        let id: Int
        let name: String
    }
}
let url = URL (string: "http: // localhost: 8000/store/api? store_id =" + store_id)
        let request = URLRequest (url: url!)
        let session = URLSession.shared
        let encoder: JSONEncoder = JSONEncoder ()
        encoder.dateEncodingStrategy = .iso8601
        encoder.outputFormatting = .prettyPrinted
        session.dataTask (with: request) {(data, response, error) in if error == nil,
            let data = data,
            let response = response as? HTTPURLResponse {
            let decoder: JSONDecoder = JSONDecoder ()
            decoder.dateDecodingStrategy = .iso8601
            do {
                let json = try decoder.decode (Store.self, from: data)
                // for store in (json.stores) {
                // for photo in (store.photos) {
                // print (photo.path as Any)
                //}
                //}

                self.store = [json]
                DispatchQueue.main.async {
                    self.nameLabel.text = json.name
                    self.locationLabel.text = json.location
                }
            } catch {
                print ("error:", error.localizedDescription)
            }
            }
            } .resume ()