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 trialEmiliano Carrillo
1,420 PointsI'm trying to count characters on a textField but it seems that .text or utf16count doesΒ΄t work anymore. Help please!
I'm trying to make a counter as in twitter but the error says: "apis deprecated as of ios 7 and earlier are unavailable in swift" I have also tried countElements( ) but nope. here is my code...
@IBAction func ContadorCaracteres(sender: AnyObject) {
var contador = 10 - countElements(sender.text) //neither utf16count
lblContador.text = "\(contador)"
}
1 Answer
Stone Preston
42,016 Pointswhat is this IBAction connected to? what are you trying to access the text property of?
Emiliano Carrillo
1,420 PointsEmiliano Carrillo
1,420 PointsIt is connected to a textField because I want to count the characters as I write them and as in twitter set a counter on the bottom (with a label) but I don't know how to count the TEXT on the textField
Stone Preston
42,016 PointsStone Preston
42,016 Pointsand on what method of the textField is it firing on?
Emiliano Carrillo
1,420 PointsEmiliano Carrillo
1,420 Pointsmmm... sorry I donΒ΄t understand IΒ΄m new to this. but I saw a guy who did it like this but it gives me the same error. I want to access to the text of the textField but don't know how :
"sender.text.utf16count"