标签:
1.从索引x位置开始取y个长度字节
NSString * str=@"1234567890";
NSString * str1=[str substringWithRange:NSMakeRange(x, y)];
2.需要个x位的字符串,当前获取的字符串y不够x位,在前面补0的方法
NSString * str=@"10101";
NSMutableString * b=[[NSMutableString alloc]initWithString:str]
if (b.length > x) {
MyLog(@"---超出x位---");
return;
}
int j = x - (int)b.length;
NSString * ing2 = [[NSString string] stringByPaddingToLength: j withString: @"0" startingAtIndex: 0];
[b insertString:ing2 atIndex:0];
标签:
原文地址:http://www.cnblogs.com/tongyuling/p/4613711.html