ios判断NSString的length

//方法一:
 - (NSUInteger)wordCount:(NSString *)str {  
 NSUInteger words = 0;   
 NSScanner *scanner = [NSScanner scannerWithString: str]; 
  
 // Look for spaces, tabs and newlines  
 NSCharacterSet *whiteSpace = [NSCharacterSet whitespaceAndNewlineCharacterSet];  
 while ([scanner scanUpToCharactersFromSet:whiteSpace intoString:nil])
 words++;  
 return words;
 }
 
 //方法二:
 - (int)countWord:(NSString*) s{
   int i,n=[s length],l=0,a=0,b=0;
   unichar c;
   for(i=0;i


 

 转载至: http://www.cnblogs.com/songuangzhi/archive/2012/08/10/2632238.html

你可能感兴趣的:(IOS)