gpt4 book ai didi

ios - stringByReplacingOccurrencesOfString : doesn't work

转载 作者:行者123 更新时间:2023-11-28 17:58:15 29 4
gpt4 key购买 nike

我希望我的输出是“23”,但它仍然显示“123”。

NSString *valorTextField = [[NSString alloc] initWithFormat:@"123"];
[valorTextField stringByReplacingOccurrencesOfString:@"1" withString:@""];
NSLog(@"%@", valorTextField);

最佳答案

stringByReplacingOccurrencesOfString 返回一个字符串:

NSString *valorTextField = [[NSString alloc] initWithFormat:@"123"];
NSString *replaced = [valorTextField stringByReplacingOccurrencesOfString:@"1" withString:@""];
NSLog(@"%@", replaced);

或者,您可以使用 NSMutableString 并使用replaceOccurrencesOfString:withString:options:range: 方法。

关于ios - stringByReplacingOccurrencesOfString : doesn't work,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20957290/

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