本帖最后由 aofex 于 2015-7-11 21:08 编辑
#import "NSString+number.h"
@implementation NSString (number)
+ (int)numberCountOfString:(NSString *)str
{
int count = 0;
for (int i =0; i<str.length; i++)
{
unichar c = [str characterAtIndex:i];
if( c >='0' && c<='9')
{
count ++;
}
}
return count ;
}
- (int)numberCount
{
int count = 0;
for (int i=0; i<=self.length; i++)
unichar c = [self characterAtIndex:i];
if(c >='0' && c <='9')
{
count++;
}
return count;
}
@end
这是个.m文件 标绿色的调用方法就没问题 ,而下边标红的那个方法怎么都用不了 提示Exceped expression. |
|