gpt4 book ai didi

iphone - 在 Objective-c 中截断字符串并在末尾添加省略号

转载 作者:技术小花猫 更新时间:2023-10-29 10:28:44 26 4
gpt4 key购买 nike

如何在 Objective-C 中截断字符串,然后在末尾添加省略号?

最佳答案

NSString *origString = @"A very long string blah blah blah";
const int clipLength = 18;
if([origString length]>clipLength)
{
origString = [NSString stringWithFormat:@"%@...",[origString substringToIndex:clipLength]];
}

关于iphone - 在 Objective-c 中截断字符串并在末尾添加省略号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6753979/

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