I'm saving my data from my main app in a file that is stored somewhere in userDomainMask.
NSKeyedArchiver.archiveRootObject(stops, toFile: BusStop.ArchiveURL.path)
and this is in my BusStop class file
static let DocumentsDirectory = FileManager().urls(for: .documentDirectory, in: .userDomainMask).first!
static let ArchiveURL = DocumentsDirectory.appendingPathComponent("stops")
Now I want to read this data from my Today Extension and its returning empty set [], so I know where the issue is. I need to save this data in a shared app group that my both Extension and App belongs to.
How do I save data and read from it?
I want to save an array of instances of my BusStop class.
EDIT:
I fixed my problem!
Use this solution:
static let ArchiveURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.asd.asd.asd")!
.appendingPathComponent("mypath")
and every time you are doing some operation on already saved data or you are saving new content use this solution:
https://stackoverflow.com/a/37162883/3595696
Cheers!