gpt4 book ai didi

swift - 从 swift 1.0 到 1.2 的固定功能

转载 作者:行者123 更新时间:2023-11-28 07:06:17 24 4
gpt4 key购买 nike

我刚升级到新的 swift,不知道如何修复这个功能。有任何想法吗?我收到以下错误以及我的第一行和返回行:

'(@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
}

最佳答案

试试这段代码->

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
}

关于swift - 从 swift 1.0 到 1.2 的固定功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30497073/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com