There is quite some stuff that needs to be done to make this right. Apple provides a lot information about syncing between extensions and the main application.
Take a look at the 2014 WWDC Sessions:
Session 205 - Creating Extensions for iOS and OS X (Part 1)
Session 217 - Creating Extensions for iOS and OS X (Part 2)
Furthermore, there is great Sample Code about this topic in Lister, a productivity sample app by Apple.
In a nutshell:
Both the main app and the extension have to be in an App Group, so that they can share the data. Use NSFileCoordinator to read and write the shared data. (to avoid corrupted files)