Call coreData object defined in another class

The following code in vc prints the only defined userName in the log. All I want to do is know what to call in twoViewController so I can print the same userName. I want viewcontroller and twoViewController to print the same thing in the log file. I think using core data and defining a username in viewcontroller I should just be able to call something in twoViewController to have it be displayed in the log file.

viewcontroller

      import UIKit

    class ViewController: UIViewController {
var user:[User]? = nil
override func viewDidLoad() {
    super.viewDidLoad()
    if coreDataHandler.saveObject(username: "soda", password: "df3")
    {
    user = coreDataHandler.fetchObject()

    for i in user! {
        print(i.username!)
    }}}

}

twoViewController

    import UIKit

   class twoViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
}}

This topic was automatically closed after 166 days. New replies are no longer allowed.