标签:区分 dex out 截取字符串 strong 区分大小写 1.2 2.3 orm
2. substringToIndex:7:截取从0 索引到指定索引(7)长度的字符串 (从0到7)
3. substringFromIndex:9:截取从指定索引(9)到末尾长度的字符串 (从9到0)
4. substringWithRange:NSMakeRange(4,2):截取从指定索引(4)到指定(2)长度的字符串 (从4开始后的2个)
5. isEqualToString:@"p://www":比较字符串包含关系,区分大小写
6. stringWithFormat:格式化字符串。
NSString *a = @"1.2.30";
int b= [[a substringWithRange:NSMakeRange(4,2)] intValue];
NSLog(@"a:%@ \n",a );
NSLog(@"b:%d",b );
Output : 2011-07-05 11:49:08.170 Q[4005:207] a:1.2.30
2011-07-05 11:49:08.172 Q[4005:207] b:30
解析如下:substringWithRange: 专门截取字符串的一块
NSMakeRange(4,2) 从第4个字符开端截取,长度为2个字符,(字符串都是从第0个字符开端数的哦~!)
二 。 字符串截取到第n位 (substringToIndex: n)(第n 位不算再内)
NSString *a = @"i like long dress";
NSString *b = [a substringToIndex:4];
NSLog(@" b: %@",b);
2011-07-11 18:12:40.119 Q[6321:207] b: i li
三 。字符串从第n 位开端截取,直到最后 (substringFromIndex:n)(包含第 n 位)
NSString *a = @"i like long dress";
NSString *b = [a substringFromIndex:4];
NSLog(@"b: %@",b);
2011-07-11 18:15:08.125 Q[6366:207] b: ke long dress
标签:区分 dex out 截取字符串 strong 区分大小写 1.2 2.3 orm
原文地址:http://www.cnblogs.com/Lovexiaohuzi/p/6956967.html