Previous episode: 14. JSON Encoding
Next episode: 16. Codable Hierarchies
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
Time to save the array of prioritized tasks. Update the save prioritized task method to achieve this. Additionally, try to improve the output format of the JSON in your file, so it's easier to read. Have fun and see you back in a bit! (upbeat music) The first thing I did was update the method signature so it reflects that we are storing multiple tasks and not just one. Next up is storing the array of prioritized tasks. Yap, its that simple. You simply pass your prioritized tasks array and you're done! Almost, be sure to clean up the code that writes your data to the file in order to use the new constant name, as well as the URL you declare in the class, right at the end of the last video. Build and run your app, make sure you still have the prioritizedtasks.JSON file in the document directory, and try adding a task. Tada, you now have an array of prioritized tasks, but the formatting is making it difficult to really make out each task and their details. This is where the bonus objective comes in. You can tell Jason and Kuru that you want to use a pretty format. Add this line right after creating your encoder. If you run your app and create or delete a task now, you will notice the resulting file is much easier to read.
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.