IPhone : How do I set a boolean flag on a different view Controller from another?

on Sunday, April 19, 2015

I have this code:



override func collectionView(collectionView: UICollectionView, shouldHighlightItemAtIndexPath indexPath: NSIndexPath) -> Bool {

var segue = UIStoryboardSegue()
let viewController = ViewController()
viewController.check == true
let photo1 = photos[indexPath.row]
viewController.photo = photo1
performSegueWithIdentifier("showDetail", sender: self)
return true
}


I only want certain code to execute if an item is selected. So my plan is to create a flag for checking. The problem here is the flag viewController.check == true never gets set to true when I arrive on the next view controller. I have tested it with println() and stuff, it's not setting at all. What am I doing wrong? How else should I do it?


0 comments:

Post a Comment