Passing data from vc1 to vc2 programmatically using present or push?

72 Views Asked by At

This is my code in VC1

I have this var user = User() in VC1 that has all the data.

func handleMessageView() {
            let layout = UICollectionViewFlowLayout()
            let messageViewController = MessageViewController(collectionViewLayout: layout)
            messageViewController.user = user
            let messageNavController = UINavigationController(rootViewController: messageViewController)
            self.present(messageNavController, animated: true, completion: nil)
        }

This is called by a UIBarbutton.

in VC2 I just have a recieving var. var user = User() This var is returning a nil, Im not using storyboard nor xib. This is all programmatic.

0

There are 0 best solutions below