Showing posts with label pass data. Show all posts
Showing posts with label pass data. Show all posts

Wednesday, May 18, 2016

Passing Data through Segue

The first thing you need to do is attach a segue from one view controller to another. Do NOT attach a segue from a button to a view controller or this will not work.
 
class FirstVC: UIViewController {
    
    @IBAction func ToSecondVC(sender: AnyObject) {
        let data = "Pass this to next view controller"
        performSegueWithIdentifier("ToSecondVCSegue", sender: data)
    }
    
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        let secondVc = segue.destinationViewController as! SecondVC
        secondVc.data = sender as? String
    }
}

class SecondVC: UIViewController {

    var data: String?
    
    @IBOutlet weak var dataLabel: UILabel!
    
    override func viewDidLoad() {
        dataLabel.text = data
    }
}
 

(Swift 2.2)

SwiftUI Search & Filter with Combine - Part 3 (iOS, Xcode 13, SwiftUI, 2...

In part 3 of the Searchable video series, I show you how to use Combine in #SwiftUI for the search and filter logic connected to the searcha...