美文网首页
读取字符串长度

读取字符串长度

作者: 路这么长 | 来源:发表于2016-11-18 16:10 被阅读11次
//字符串中的字符长度 - (int)convertToInt:(NSString *)strTemp {      
 int strLength = 0;   
 char *p = (char *)[strTemp cStringUsingEncoding:NSUnicodeStringEncoding];  
  for (int i = 0 ; i < [strTemplengthOfBytesUsingEncoding:NSUnicodeStringEncoding]; i++) {     
   if (*p) {         
         p++;            
         strLength++;      
  }
   else {         
         p++;       
     }    
   }    
        return strLength;
}

相关文章

网友评论

      本文标题:读取字符串长度

      本文链接:https://www.haomeiwen.com/subject/ddqspttx.html