Loading data from user defaults

- Now that we've saved our data to User Defaults,…let's look at loading data from User Defaults.…So I'm in Note.swift, and I'm going to scroll down…right below the "saveNotes" method,…and I'm going to create another class method…called "loadNotes".…So in here we're going to load the data…for the User Defaults and then we're going to do…the opposite of what we did in "saveNotes".…We're going to take that raw dictionary…with values and keys,…and we're going to apply it to notes…and repopulate our "allNotes" array.…

So we'll start by creating a variable called "defaults",…and this is going to be of the type NSUserDefaults.…I'm just doing this to conserve line space…so we don't need a special variable to hold this.…So I'm going to set this equal to…"NSUserDefaults.standardUserDefaults",…so now I can just reference that whole long code…with this short code in my variable here.…So now I'll create a variable called "savedData",…and this is what's going to grab that data…from our User Defaults,…this is going to be an array of NSDictionaries,…

Resume Transcript Auto-Scroll

Author

Released

11/7/2014

Building an app for just one mobile platform isn't good enough anymore. But beginning with iOS is a great start. This course helps you build a simple note-taking app in iOS 8, one you can then re-create for Android and Windows Phone in Building a Note-Taking App for Android and Building a Note-Taking App for Windows Phone 8 and Windows Store.

Each of these courses helps you build a complete mobile app from scratch; this installment uses the iOS SDK and Xcode to get the job done. Author Todd Perkins shows you how to create an Xcode project, lay out apps visually, connect UI elements to code, and save data to persistent storage. Start here with iOS 8, and compare your results with the Android and Windows Phone courses to learn about the differences and similarities of these mobile platforms.