時,我有以下代碼:獲得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