Getting Started with JSON Files
In the previous chapter, you modified the Add Journal Entry screen so that the user can add their current location to a new journal entry, and configured the Map screen to display a region centered on your current location as well as pins representing the location where the journal entries are made. However, since the JournalListViewController
class and the MapViewController
class are using separate instances of the SampleJournalEntryData
structure, newly added journal entries do not appear on the Map screen as pins. Also, all the journal entries are lost when you quit the app.
In this chapter, you will create a singleton, SharedData
, that will provide journal entry data to both the Journal List and Map screens. This class will also be used to load journal entry data from a file on your device when the app starts up and save journal entry data to a file on your device when you add or delete journal entries.
You’ll start by creating the...