I've been recently trying to migrate my app into an MVC format and I was wondering how one would go about accessing a View Controller's variables (trying to access them FROM a .swift file) without having to create a new instance of the View Controller. For example:
HomePageViewController().objectIDs.append(post.objectId!)
HomePageViewController().postTitles.append(post["Title"] as! String)
HomePageViewController().imageFiles.append(post["imageFile"] as! PFFile)
HomePageViewController().descriptions.append(post["description"] as! String)
HomePageViewController().userNames.append(post["originalPosterUserName"] as! String)
HomePageViewController().numOfComments.append(String(describing: post["numberOfComments"]!))
print(HomePageViewController().userNames, "This is a test")
The print statement at the end prints '[]This is a test' with no data inside of the array. Inside of the HomePageViewController file, this works perfectly though. I'm assuming that this isn't working due to me creating a new instance of the HomePageViewController and altering THOSE variables rather than the current one. So, my question is, how would I be able to alter the variables of the current HomePageViewController without the need to create a new instance?
A solution like this wouldn't work either since I have multiple classes with the same variable names.
I'd appreciate any help. Thanks!