I would like to write in the text or csv (prefer) file the variable from the view controller.
Indeed I am doing a drawing app and I would like to write in the file the current position of the finger.
class ViewController: UIViewController {var lastPoint = CGPoint.zeroPoint ... }
I would like to have access to lastPoint.x and lastPoint.y from the AppDelegate. how I could do that ? Thank you.
Your question is full of confusion but if that's what you are looking for:
You can access the appDelegate by getting a reference to it like that:
after that if you have store a property called lastPoint in your appDelegate you can access its components very simply like that:
If you need to access your viewController properties from the AppDelegate, then I suggest having a reference to your view controller in your appdelegate:
then when your view controller is created you can store a reference to it in the appdelegate property:
If your create your view controller outside of your appDelegate:
Swift 1-2 syntax
Swift 3-4 syntax
If you create your view controller inside of your appDelegate:
After that you can access your data from your viewcontroller from your appdelegate just by accessing its property like that: