@interface NSString (NSStringWithOctal)
-(int)octalIntValue;
@end
@implementation NSString (NSStringWithOctal)
-(int)octalIntValue
{
int iResult = 0, iBase = 1;
char c;
for(int i=(int)[self length]-1; i>=0; i--)
{
c = [self characterAtIndex:i];
if((c<'0')||(c>'7')) return 0;
iResult += (c - '0') * iBase;
iBase *= 8;
}
return iResult;
}
@end
nsstring +octal
最新推荐文章于 2016-01-26 12:11:19 发布