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

Fabian Ullrich
Fabian Ullrich
2,442 Points

What is .toInt() from Swift in swift 2.1 ?

I'm learning Swift with Amit but the problem is that he uses Swift 1 and my version of Xcode is using Swift 2.1 (I guess) so when it comes to optionals and converting a string called "101" into an integer he writes culprit.toInt()! //culprit is the variable. When I copy his code in Xcode, the program doesn't know .toInt() ! Does anyone know how to put this in a newer version of Swift/Xcode?

1 Answer

Fabian Ullrich
Fabian Ullrich
2,442 Points

Thank you very much, Jason!!! For everyone else: it is not anyString.toInt() anymore but Int(anyString)