大牛看看这个错误__NSCFString deleteCharactersInRange:]: Range or index out of bounds'
下面上代码
NSUserDefaults *userdefault = [NSUserDefaults standardUserDefaults];
NSString *stuffId = [userdefault objectForKey:SStuffID];
NSMutableString *attrType = [NSMutableString string];
if ([self.idDictionary allValues] != 0) {
for (NSInteger i = 0; i < [self.idDictionary allValues].count; i++) {
[attrType appendString:[self.idDictionary allValues]];
[attrType appendString:@","];
}
[attrType deleteCharactersInRange:NSMakeRange(attrType.length -1, 1)];
}
NSLog(@"-=-=-=--=-=%@",stuffId);
错误
2015-10-30 15:00:48.277 yqApp[14197:1321607] *** Terminating app due to uncaught exception 'NSRangeException', reason: '-[__NSCFString deleteCharactersInRange:]: Range or index out of bounds'
*** First throw call stack:
(0x24350f87 0x31973c77 0x24350ecd 0x2430cc0d 0x28abbd 0x28cba3 0x27800497 0x27963fcd 0x27800497 0x27800439 0x277eb04d 0x277ffe69 0x277ffb43 0x277f9451 0x277cfcc5 0x27a43513 0x277ce707 0x24317807 0x24316c1b 0x24315299 0x24262db1 0x24262bc3 0x2b5c7051 0x2782ea31 0x18889d 0x31f0faaf)
libc++abi.dylib: terminating with uncaught exception of type NSException
执行完for循环,进入 [attrType deleteCharactersInRange:NSMakeRange(attrType.length -1, 1)];后代码报错
说是什么越界,但是怎么操作呢