本帖最后由 haha92210 于 2014-11-28 17:26 编辑
- (int)ziMuCountInStr { int count = 0; for (int i = 1; i <= self.length; i++) { unichar c = [self characterAtIndex:i];
if (c >= 'a' && c <= 'z') { count++; } } return count; }
这是输出得东西 2014-11-28 17:20:57.179 1128[27833:303] *** Terminating app due to uncaught exception 'NSRangeException', reason: '-[__NSCFConstantString characterAtIndex:]: Range or index out of bounds' *** First throw call stack: ( 0 CoreFoundation 0x00007fff8ec6a25c __exceptionPreprocess + 172 1 libobjc.A.dylib 0x00007fff93614e75 objc_exception_throw + 43 2 CoreFoundation 0x00007fff8ec6a10c +[NSException raise:format:] + 204 3 CoreFoundation 0x00007fff8eb5178b -[__NSCFString characterAtIndex:] + 91 4 1128 0x000000010000174d -[NSString(MJ) ziMuCountInStr] + 93 5 1128 0x0000000100001a59 test3 + 57 6 1128 0x00000001000019a4 main + 36 7 libdyld.dylib 0x00007fff92f4e5fd start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)
|