NSString 剪切一个字符串 deleteCharactersInRange

NSMutableString   为可变的字符串

    NSString       为不可变的字符串


- (void)viewDidLoad

{

    NSMutableString *a = [[NSMutableString  alloc] initWithString:@"123456798"];

    NSLog(@" \n a:  %@ \n",a);

    [a deleteCharactersInRange:NSMakeRange(1, 2)];

    NSLog(@" \n a:  %@ \n",a);

    [a release];

}

 

2011-07-05 20:59:34.169 Q[9069:207]    a:  123456798 

2011-07-05 20:59:34.171 Q[9069:207]    a:  1456798 


deleteCharactersInRange   为剪切 字符串 ,按照range的要求,从第几个开始 , 剪切的长度为2

你可能感兴趣的:(oc)