ios nsstring怎么从后面开始截取字符串
1个回答
展开全部
//有两种方法
NSString *originalString = @"I wanna go to the Rio Olympics";
//1.substringFromIndex: 从第18位字符开始到最后的字符的字符串截取
NSString *subfixString = [originalString substringFromIndex:18];
//2.substringWithRange: 从第18位字符开始,长度为(总长度-18)的长度的字符串载取
NSString *rangeString = [originalString substringWithRange:NSMakeRange(18, originalString.length-18)];
NSLog(@"sub=%@,\nran=%@",subfixString,rangeString);
//输出结果为:
//--2016-08-09 10:33:06.764 Objective-c-Practise[99217:10851975] sub=Rio Olympics,
//--ran=Rio Olympics
NSString *originalString = @"I wanna go to the Rio Olympics";
//1.substringFromIndex: 从第18位字符开始到最后的字符的字符串截取
NSString *subfixString = [originalString substringFromIndex:18];
//2.substringWithRange: 从第18位字符开始,长度为(总长度-18)的长度的字符串载取
NSString *rangeString = [originalString substringWithRange:NSMakeRange(18, originalString.length-18)];
NSLog(@"sub=%@,\nran=%@",subfixString,rangeString);
//输出结果为:
//--2016-08-09 10:33:06.764 Objective-c-Practise[99217:10851975] sub=Rio Olympics,
//--ran=Rio Olympics
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询