I am trying to create a Today Extension Widget which displays stored data in the widget.
Here's what I have done;
- Added New Today Widget Target
- Set up UIViewController for widget
- Enable App Groups for both the app and extension
Now I have hit a road block, I am unsure the best way to retrieve and display a simple array of fetched data.
There is very little Swift tutorials and they often do not use core data.
In the main app project I fetch the array.
let moc = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext
let request = NSFetchRequest(entityName: "Objects")
do {
try
self.objectsArray = moc.executeFetchRequest(request) as! [Objects]
} catch {
}
How can I use NSUserDefaults
to store the objects array and then use in the today widget extension ? Or Even an array of string values.