读取字符串长度
2016-11-18 本文已影响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;
}