NSString *str = @"my name is jiemu";
1.从第三个字符开始,截取长度为4的字符串
NSString *str2 = [str substringWithRange:NSMakeRange(3,4)];//str2 = "name"
2.截取到第n为(第n位不算在内)
NSString *str3 = [str substringToIndex:2];//str3 = "my"
3.从第n为开始直到最后(包含第n位)
NSString *str4 = [str substringFromIndex:11];//str4 = "jiemu"
时间: 2024-10-25 01:28:23