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.
Back-to-back challenges, huh? Whew! Don't worry, as you saw in the previous video, it's really simple to migrate from using JSONE to using .plists. Similar to what you did in the previous challenge, add a new method to load your prioritized tasks from the .plist file, and load them up when you initialize the task store. Have at it! (funky music) First, I added a new method to load the data from a .plist. Then, I copied the do catch statement from the JSON loading method and simply updated the URL to read from. Next stop is creating a decoder, which you can do at the top of the method. The last thing you wanna do now is use this method when initializing task store. Run your app, and voila! You now have loaded the same .plist data that you previously stored in your document directory. One final bonus item is that if you launch the app for the first time, and there is no data file to load from your document directory, then the console will print out a warning. You can mitigate that by checking if the file exists prior to loading it. Do that with the following call at the top of your new method. Run your app again, and check out the results. No error message. Fantastic. Here you rely on file manager once again in order to check whether a file exists at a given path. Since you already have the URL to the file, you simply pass that as the parameter. And if the file doesn't exist, you break out of the method. The file will get created whenever any modifications are made to your tasks. Subsequent app launches will result in your app getting past discard statement and correctly loading the .plist data.
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.