在某些时候,我分配了一个 NSMutableData 元素,如下所示:
NSMutableData* data=[[NSMutableData alloc] initWithLength:0];
后来,我这样做:
NSString *dataAsStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] ;
completeCommand = [NSString stringWithFormat:@"%@%@",
incompleteMessage,
[dataAsStr substringWithRange:NSMakeRange(startIndex, i-startIndex)]];
[incompleteMessage release];
incompleteMessage = nil;
[dataAsStr release];
最后我打电话给:
[data release]; //Here I get a BAD_ACCESS error since data gets a release count of -1
现在根据仪器(支持僵尸的分配),第二块 NSString *dataAsString = ... 的第一行调用 [data release]
发生在哪里?