Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Playlist Browser with Swift Building the Master and Detail Views Adding Touch Capabilities

Philip Micallef
Philip Micallef
1,962 Points

Need Help - Tap is not registering, No ERRORS

I think the problem has something to do with the connections. I have reconnection the Outlets and Actions, Even Clean the App as well. As the App is running the connection symbols on the side where the line numbers are become hollow. Tap is not registering any more. No Errors Found. Please Help

import UIKit

class PlaylistMasterViewController: UIViewController {


    var playlistsArray: [UIImageView] = []

    @IBOutlet weak var playlistImageView0: UIImageView!

    override func viewDidLoad() {
        super.viewDidLoad()
        playlistsArray.append(playlistImageView0)



        for index in 0..<playlistsArray.count {
            let playlist = Playlist(index: index)
            let playlistImageView = playlistsArray[index]

            playlistImageView.image = playlist.icon
            playlistImageView.backgroundColor = playlist.backgroundColor

        }

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        if segue.identifier == "showPlaylistDetailSegue" {


            let playlistImageView = sender!.view as! UIImageView

            if let index = find(playlistsArray, playlistImageView) {


                let playlistDetailController = segue.destinationViewController as!
                PlaylistDetailViewController

                playlistDetailController.playlist = Playlist(index: index)

            }

        }
    }


    @IBAction func showPlaylistDetail(sender: AnyObject) {
        performSegueWithIdentifier("showPlaylistDetailSegue", sender: sender)
        }




}

2 Answers

Animesh Mishra
Animesh Mishra
2,393 Points

In Interface Builder, select the UIImageView, go to Attributes Inspector and under View check User interaction enabled and Multiple Touch.

Caleb Kleveter
MOD
Caleb Kleveter
Treehouse Moderator 37,862 Points

What happens if you change this:

 for index in 0..<playlistsArray.count {

to this:

 for index in 0..<playlistsArray.count> {
Philip Micallef
Philip Micallef
1,962 Points

I get an Error in that line saying ... '>' is not a postfix unary operator