时,我有以下代码:获得EXC_BAD_ACCESS试图ADDOBJECT到NSMutableArray的
NSInteger phoneCount = ABMultiValueGetCount(phones);
NSMutableArray *phoneKeys = [[[NSMutableArray alloc] init] autorelease];
NSMutableArray *phoneKeyValues = [[[NSMutableArray alloc] init] autorelease];
for(CFIndex i=0; i < phoneCount; i++) {
//NSString *label = [(NSString *)ABMultiValueCopyLabelAtIndex(phones, i) autorelease];
NSString *phone = [(NSString *)ABMultiValueCopyValueAtIndex(phones, i) autorelease];
NSString *phoneIndex = [[[NSNumber alloc] initWithInt:ABMultiValueGetIdentifierAtIndex (phones, i)] autorelease];
[phoneKeys addObject:phoneIndex]; // it breaks on this line
}
NSLog(@"Count: %@ %@", [phoneKeys count], [phoneKeyValues count]);
任何想法,为什么我会得到EXC_BAD_ACCESS,当我尝试做[phoneKeys ADDOBJECT:phoneIndex]?
在此先感谢
您是否尝试过删除NSLog行? – kennytm 2010-08-29 18:13:36
嗯你是对的。这是否意味着phoneKeys正在发布太快? – john 2010-08-29 18:16:54
你的意思是它在删除NSLog后工作? – kennytm 2010-08-29 18:20:34