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 Adding Multiple Playlists

find has been explicitly marked unavailable here

when working on this code, I am unable to use the 'find' method and being prompted to use 'indexOf' instead which does not seem to be a viable option

my code is an exact replace (save some conversions of as to as!) of the project files

any help would be appreciated!

2 Answers

Nathan B
Nathan B
4,905 Points

The find() function is no longer supported in Swift 2.0. To modify the code to work with Swift 2.0 and Xcode 7, use:

playlistsArray.indexOf(playlistImageView)

Good catch! I didn't notice that because I'm not using Swift 2.0. We should add a field to all forum posts for people to specify what version of code they're using. It's surprising how many people we have using Beta versions, though, for beginner-level courses.

It's very hard to answer this question without actually looking at your code.

I also typed in the same code, while following the videos, but I did not get the error message you're getting. That rules out something along the lines of as vs. as!, which was a version issue, because I'm using the newest version, which Pasan didn't have. Can I assume you're also on the latest version of XCode? There is no problem with the find command on my computer.

Most likely issue I can think of is a typo, some minute difference between Pasan's code and yours, but how can we track it down if we can't view your code?