欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > > 文章正文

substringFromIndex 和 substringToIndex用法,

来源: javaer 分享于  点击 5515 次 点评:174

substringFromIndex 和 substringToIndex用法,


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.

返回一个字符串,这个字符串截取接受对象字符串范围是给定索引index到这个字符串的结尾


- (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

相关文章

    暂无相关文章

用户点评