I've got a Graph class which is an UIView and I'm initializing it inside mainVC.swift
:
class MainVC : UIViewController{
let graph : Graph!
override func viewDidLoad(){
super.viewDidLoad()
let data_x : [Double] = [...]
let data_y : [Double] = [...]
...
graph = Graph(frame: CGRect(...), color: ..., xData: data_x, yData: data_y, darkMode: ...)
view.addSubview(graph)
...
}
Now I would like to access function inside instance of the class which I've created in MainVC in different class (to populate data in TableView).
var g : Graph = MainVC.graph
returns "Instance member graph cannot be used on type MainVC"
I've also tried using static variable but there was an error.