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 locations where the journal entries are made. However, since the MapViewController
instance does not have access to the journalEntries
array in the JournalListViewcontroller
instance, newly added journal entries do not appear on the Map screen as pins. Also, all newly added 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 SharedData...