TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

SOLVED: Day 59: Milestone Project 13-15 (Load JSON challenge)

Forums > 100 Days of Swift

Hey everyone, I am having a challenge with loading the names of the country (from my created JSON file) to the table view. If you can kindly assist, here is the link to the GitHub repository where the project resides: https://github.com/leonardsangoroh/AfricanCountriesInfo Any help will be much appreciated.

Thank you in advance :)

1      

Three steps to be made

  • Open your json file and remove this stuff at lines 433 - 435
  • You json has propery "countries" not "results" so you have to modify your Countries struct to
    struct Countries: Decodable {
    var countries: [Country]
    }

and while decoding to this

countries = jsonCountries.countries
  • And finally in your Country struct update property
    var officialLanguage: String // this is string type not an array of strings!!!

1      

@ygeras Thank you for your response.

I have made the first three changes and still the country names are not loading.

As for change 4, I am not sure if I should make is since some of the countries have more than one official language

Could there be an issue with the storyboard rather than the code?

1      

Unless you do this var officialLanguage: String nothing will work. Yes, you have several languagues but this is still a string not array.

"Language 1, Language 2, etc" it is a string not an array.

I wrote all the steps after only making abovementioned changes. Otherwise it didn't work :)

1      

Thank you very much :) It is now properly working

Thank you once again.

1      

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.