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
Euan Maley
1,465 PointsCan anyone make this line of swift into swift 2.0? currentNumber * 10 + Float(sender.titleLabel!.text!.toInt()!)
currentNumber = currentNumber * 10 + Float(sender.titleLabel!.text!.toInt()!) im making a calculator and this is the line of code stopping me.
1 Answer
Jhoan Arango
14,575 PointsHello:
Quick question, what version of swift are you using ?
Try this
currentNumber * 10 + Float(Int(sender.titleLabel!.text!)!)
My question is, why are you changing it from Int, to float ? I think you can do something like this, and skip the int casting.
currentNumber * 10 + Float(sender.titleLabel!.text!)
Good luck let me know if it works.
Euan Maley
1,465 PointsEuan Maley
1,465 PointsThe first line of code works for my calculator, but the second line doesnt let my buttons display anything on the label. And i was wondering if there are any good guides for making a calculator with all basic functions + more using swift 3? I cant seem to find any.