rangeOfCharacterFromSet究竟做了什么?

时间:2009-08-07 01:32:59

标签: iphone objective-c cocoa

  NSString *foo = @"     x   ";
  NSRange r = [foo rangeOfCharacterFromSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
  NSLog(@"foo range = %d,%d",r.location, r.length);

结果为“foo range = 0,1”

所以它会返回长度> 1?