Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS

Build a Playlist Browser

Keeping it short, I had some mac issues and lost all of my apps. I downloaded the Build a Playlist Browser files and allowed Xcode to make the updates to it. All but one error were fixed. Does anybody know what to do about this? It's in the PlaylistMasterViewController. It says 'find' is unavailable: call the indexOf() method of collection.

import UIKit

class PlaylistMasterViewController: UIViewController {

var playlistsArray: [UIImageView] = []
@IBOutlet weak var playlistImageView0: UIImageView!
@IBOutlet weak var playlistImageView1: UIImageView!
@IBOutlet weak var playlistImageView2: UIImageView!
@IBOutlet weak var playlistImageView3: UIImageView!
@IBOutlet weak var playlistImageView4: UIImageView!
@IBOutlet weak var playlistImageView5: UIImageView!


override func viewDidLoad() {
    super.viewDidLoad()

    playlistsArray += [playlistImageView0, playlistImageView1, playlistImageView2, playlistImageView3, playlistImageView4, playlistImageView5]

    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)
}

}

1 Answer

Never mind I wasn't putting playlistArray before indexOf.