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

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)