I created a var in my ViewController:
class ViewController: UIViewController {
var options: Options?
}
In viewWillAppear I set the options
/ grab the options
let optionsFetch: NSFetchRequest<Options> = Options.fetchRequest()
do{
let results = try coreDataStack.managedContext.fetch(optionsFetch)
if(results.count > 0){
options = results.first
}
}catch let error as NSError{
print("\(error) is the error")
}
I also have an extension of this:
extension UIViewController {
func myMethod() {
let color = options.color
}
I can't seem to access the options var from within the extension. I found this post, and thought I had followed what they were saying, but still no luck. enter link description here