Passing data between views via segmented bar
<p>I know this is a frequently asked question throughout the forums and I hate to ask another seemingly simplistic question, but I can't manage to find a solution on data passing in regards to my specific circumstance.</p>

<p>Basically, I have a view controller embedded within a navigation controller; of which displays a segmented bar, acting as a 'profile selector'. After selection, I want a series of images on another view to be changed after different profiles are selected, but the data passing isn't seem to be working whatsoever. I'm unsure if delegate is required within my specific circumstance. </p>

<p>Essentially; I'd just love an example of how to pass a case value for a segmented bar so I would be able to perform a simple case statement like follows: (where the case values have been passed from the previous view controller)</p>

<pre><code> @IBAction func chooseImage(sender: AnyObject) {
    switch myPhotoSegment.selectedSegmentIndex {
        //if first segment selected
    case 0:
        //stop image animation if currently animating
        newImageView.stopAnimating()
        //update displayed image
        newImageView.image = UIImage(named: "1.jpg")
        //if second segment selected
    case 1:
        //stop image animation if currently animating
        newImageView.stopAnimating()
        //update displayed image
        newImageView.image = UIImage(named: "2.jpg")
        //if third segment selected
    case 2:
        //stop image animation if currently animating
        newImageView.stopAnimating()
        //update displayed image
        newImageView.image = UIImage(named: "3.jpg")
        //if fourth segment selected
    case 3:
        //stop image animation if currently animating
        newImageView.stopAnimating()
        //update displayed image
        newImageView.image = UIImage(named: "4.jpg")

        //by default, no segment selected
    default:
        newImageView.image = nil
    }
}
</code></pre>

<p>I know my problem is long and probably poorly explained, but any feedback would be greatly appreciated. I kind of struggle with the whole logic and understanding of passing data, so if you could break down the solution for me as simply as possible; that would be incredible.</p>