BLACK FRIDAY: Save 50% on all my Swift books and bundles! >>

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      

Save 50% in my WWDC sale.

SAVE 50% All our books and bundles are half price for Black Friday, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

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.