字符串的截取

- (void)viewDidLoad {

[super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.

NSString * str = @"asfawre";

//    2015-12-15 10:24:56.828 试炼[868:24347] 7

//    2015-12-15 10:24:56.829 试炼[868:24347] awre

//    2015-12-15 10:24:56.829 试炼[868:24347] asf

//    2015-12-15 10:24:56.829 试炼[868:24347] faw

NSLog(@"%lu",str.length);

NSLog(@"%@",[str substringFromIndex:3]);

NSLog(@"%@",[str substringToIndex:3]);

NSLog(@"%@",[str substringWithRange:NSMakeRange(2, 3)]);

}

你可能感兴趣的:(字符串的截取)