以下是基本操作字符串大小的示例.
int max = 5;
Run Code Online (Sandbox Code Playgroud)
NSArray *strs = [NSArray arrayWithObjects:@"My Little Puppy", @"Yorkerz", nil];
Run Code Online (Sandbox Code Playgroud)
[strs enumerateObjectsUsingBlock:^(NSString *str, NSUInteger idx, BOOL *stop) {
if (str.length > max)
//get a modified string
str = [str substringToIndex:str.length-(str.length-max)];
NSLog(@"%@", str);
}];
Run Code Online (Sandbox Code Playgroud)
"My Li" and "Yorke"
Run Code Online (Sandbox Code Playgroud)
希望,我从你的问题中理解.
| 归档时间: |
|
| 查看次数: |
4518 次 |
| 最近记录: |