NSString *testsubstringToorFromIndex = @"test1234";
NSString *fromIndexstring = [testsubstringToorFromIndex substringFromIndex:2];
NSString *toIndexstring = [testsubstringToorFromIndex substringToIndex:2];
NSLog(@"subtringfromindex is %@",fromIndexstring);
NSLog(@"subtringToindex is %@",toIndexstring);
输出结果
2014-11-29 06:23:59.634 sdktest[587:11024] subtringfromindex is st1234
2014-11-29 06:23:59.634 sdktest[587:11024] subtringToindex is te
- (NSString *)substringFromIndex:(NSUInteger)anIndex
Description
Returns a new string containing the characters of the receiver from the one at a given index to the end.
- (NSString *)substringToIndex:(NSUInteger)anIndex
Description
Returns a new string containing the characters of the receiver up to, but not including, the one at a given index.
返回一个字符串,这个字符串截取接受对象字符穿范围是从索引0到给定的索引index