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

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值