Reputation: 1635
I just upgraded to the new swift and can't figure out how to fix this function. Any ideas? I get the error below and my first and return lines:
'(@Ivalue String!) -> _' is not identical to 'NSInteger'
func textView(textView: UITextView, shouldChangeTextInRange range: NSRange, replacementText text: String) -> Bool {
var countx = count(textView.text) + (count(text) - count(range))
var t = String(countx) + "/500"
countText.text = t
return count(textView.text) + (count(text) - count(range)) <= 500
}
Upvotes: 1
Views: 75
Reputation: 1635
Thanks for the answers, was very helpful. Turns out I had a variable named count
. Since the function was countElements
before there was no conflict.
Upvotes: 0
Reputation: 822
Try this code ->
func textView(textView: UITextView, shouldChangeTextInRange range: NSRange, replacementText text: String) -> Bool {
let countx = count(textView.text) + (count(text) - range.length)
countText.text = "\(countx)/500"
return countx <= 500
}
Upvotes: 1
Reputation: 972
Convert Swift 1.0 to Swift 1.2 First you select a target and then it’s very similar to how refactoring works – Xcode will churn away and then come back with a preview. You’ll see the old code and new code side-by-side with the changes highlighted.
Go Edit\Convert\To Swift 1.2
I hope its work....
Upvotes: 0