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 Swift Functions and Optionals Optionals Optional Chaining

I get this error in the example with optionals/optionals chaining:

https://www.dropbox.com/s/e7h2sxjt63lczhd/Screenshot%202014-12-01%2008.06.59.png?dl=0

I guess the compiler is complaining about the String format in the array is not equal to the String format in the function parameter?

PS: Im a noob. Handle with care :)

2 Answers

The compiler is telling you that the array "aptNumbers" is not a String, it's an array, and can't be converted into a String. What's the problem here? You're comparing a String to an Array in your for-in loop. You should trying comparing "tempAptNumbers," which is a String object in the array "aptNumbers" to another String. Replace "aptNumbers" in your for-in loop to something like "404" and see what you get.

if (tempAptNumber == aptNumber) { return aptNumber }