gpt4 book ai didi

nsstring - stringByReplacingCharactersInRange 如何快速工作?

转载 作者:搜寻专家 更新时间:2023-10-31 23:05:35 25 4
gpt4 key购买 nike

<分区>

我在 objective-c 中有这段代码:

[textField.text stringByReplacingCharactersInRange:range withString:string];

尝试转换为 swift,像这样:

textField.text.stringByReplacingCharactersInRange(range, withString: string)

但是编译器说,Int is not identical to 'String.index'

我应该如何修改表达式?

我在 UITextFieldDelegate 方法中同时使用了 objective-c/swift 表达式:

func textField(textField: UITextField!,
shouldChangeCharactersInRange range: NSRange,
replacementString string: String!) -> Bool {

enter image description here

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