This is part of the "iOS Data and Networking" learning path. View Path

Saving Data in iOS

Apr 28 2020 · Video Course (1 hr, 41 mins) · Beginner

Find out where and how to save data in iOS! This course explores common methods for persisting user data, all from within Xcode Playgrounds.

4.2/5 9 Ratings

Version

  • Swift 5.1, iOS 13, Xcode 11

Files & Data

Introduction

5:31 Free

Welcome to the Saving Data in iOS course! Find out what you'll learn, including FileManager, the Filesystem, URLs, Foundation Data and data types, and how to save and load data using files.

1

Familiarize yourself with FileManager and how to use it to retrieve the URL for the existing Document directory.

2

Paths

4:10

Learn how to add to a URL’s paths, and customize the files and filenames you use to save data with the URL you acquire.

3

Practice working with strings and URLs to create a path and filename where data would get stored to.

4

Learn about Foundation Data and the term “Data”. Also, familiarize yourself with the basics of Swift data types and structures like Integers, Floats, Doubles, Strings, Dictionaries, Sets, and Arrays.

5

Save and load data from an array into a binary file (without an extension), as well as a file with the .txt extension.

6

String

3:48

Save an array of integers, representing emoji, and also a string to file. Also, see how you're saving emoji to a text file both as bytes of data, or as string data.

7

Try to save a string to a file and read it back, this way you'll understand what happens behind the scenes when you use the "write" method on String.

8

Conclusion

0:59

You can now work with the FileManager, the Filesystem, and Data in order to save and load data from files in your app. In this episode, find out what's next!

9

JSON

Check out what you'll be learning in this part of the course, including JSON, its structure and types, saving and loading data using JSON, and Swift's Codable protocol.

10

Get an overview of JSON, what it means, the data format, and supported data types. Then, learn how to load, or decode, data from a JSON file.

11

Use the knowledge from the previous episode to load or decode via JSONDecoder, an array of JSON data.

12

In this episode, find out how to save files on a simulator or physical iOS device. Also, learn about the app bundle.

13

Save your JSON data to disk. This will mean the app is now loading and saving its data to the app bundle.

14

This challenge asks you to handle encoding an array of JSON data to a file, as opposed to encoding a single item.

15

Get a sense of how to encode/decode codable objects within each other. Also learn about CodingKeys and how to handle mapping different JSON properties to your Swift ones.

16

Conclusion

0:54

Let's review where you are with your JSON data-saving core concepts, and discuss what's next.

17

Property Lists

This part of the course includes learning about Property Lists, how they compare to JSON, and saving and loading data via PList files.

18

Cover the basics of Property Lists, .plist files, their difference with JSON, and the data types you can store in them.

19

Take on a challenge to see if you can save your existing JSON data into a property list file instead.

20

A back-to-back challenge where you attempt to now read back the property list file you saved in the previous episode.

21

Learn about the differences of working with JSON and Property Lists, pros and cons of each, and when you’d want to consider using them.

22

Conclusion

2:27

Congrats on finishing the course! Where can you take your skills now? Learn about next steps and further resources.

23

Who is this for?

Beginner to intermediate developers. If you're a beginner developer, or if you are following our iOS learning paths, this course will teach you the foundations of saving and loading data in iOS.

This course is also a great guide for intermediate developers who would like to know more about how to work with data, files, the filesystem, and parsing data to/from JSON or Property Lists.

Covered concepts

  • Data: basic concepts
  • Available data types in Swift
  • Files & the Filesystem
  • The app bundle
  • The app sandbox
  • FileManager, URL, and Foundation Data
  • JSON and Property lists formats for storing and serializing data with the Encodable and Decodable protocols
  • How to load and save data in a real-world SwiftUI application

Contributors

Comments