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 Refactoring Our Code Determining Playlists Programmatically

Mateo Sossah
Mateo Sossah
6,598 Points

I have the same code as the video, but am getting tons of errors on a single line

For "let playlistImageView = playlistsArray[index]" I get these errors

  • type of expression is ambiguous without more context
  • type annotation missing in pattern
  • definition conflicts with previous value
  • consecutive statements on a line must be separated by ";"

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
    }
}
Steven Deutsch
Steven Deutsch
21,046 Points

Hey Mateo,

Can you show me the code for your prepareForSegue method?

1 Answer

Mateo Sossah
Mateo Sossah
6,598 Points

Hey Steven, I'm not really sure what I did (simply made the block look "cleaner" without touching the code) but it worked...

I guess I'll delete the question, but thanks for taking a look!