<分区>
我正在使用 NSString
,我想获取它的一个子字符串,其中包含我的字符串的前 20 个字符。我该怎么做?
<分区>
我正在使用 NSString
,我想获取它的一个子字符串,其中包含我的字符串的前 20 个字符。我该怎么做?
最佳答案
您可以使用substringToIndex
。
NSString *mystring = @"This is a test message having more than 20 characters";
NSString *newString = [mystring substringToIndex:20];
NSLog(@"%@", newString);
关于ios - 来自 NSString 的子字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14767167/