How to access variable from one class in another? Swift Code
<p>I am having an issue getting one simple variable from one class to another and it is beyond extremely frustrating :/...</p>

<p>Here is the deal I have two view controller classes named: <code>ViewController.swift</code> and <code>ViewController2.swift</code></p>

<p><code>ViewController.swift</code> is linked to a storyboard that has sort of an inventory bag that I have placed which is just an image. Then there is an @IBAction for when you click on the bag it opens up and the second storyboard pops into view. This is controlled by <code>ViewController2.swift</code>. All I am looking to do is simply pass the center of the bag image from ViewController to ViewController2 but I can't seem to get it to work any help would be greatly appreciated.</p>

<pre><code>class ViewController: UIViewController {
    @IBOutlet weak var InventoryBag: UIImageView!
    var bagCenter:CGPoint = CGPoint(x: 0, y: 0)

    override func viewDidLoad() {
        super.viewDidLoad()

        @IBAction func InventoryButtonTapped(sender: UIButton) {
            self.InventoryBag.image = UIImage(named: "backpackimageopen")
            bagCenter = self.InventoryBag.center

        func transferViewControllerVariables() -&gt; (CGPoint){
            return bagCenter
            }
</code></pre>

<p>When I print the bagCenter from this ViewController it works properly and gives me a correct value. So the <code>bagCenter</code> variable I would like to somehow pass over to <code>ViewController2.swift</code>. </p>

<p>Here is what I tried from <code>ViewController2.swift</code> but it never seems to work and always gives me a 0 rather than the actual value.</p>

<pre><code>class ViewController2: UIViewController {

@IBOutlet weak var HideButton: UIButton!
@IBOutlet weak var InventoryCollection: UICollectionView!



override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.

    //Load the center of the inventory bag to this view controller to align the hide button.
    var bagCenter = ViewController().transferViewControllerVariables()
}
</code></pre>

<p>But when I do this it always results in a 0 and I don't get the actual coords of the bag that are showing up in ViewController1.</p>