0
iPhone의 Phone Book에서 모든 전화 번호를 가져 오려고합니다. 하지만 kABPersonPhoneProperty를 사용하여 번호를 가져 오면 곧 내 앱이 다운됩니다. 코드 스 니펫은 여기에 있습니다.kABPersinPhoneProperty를 사용할 때 응용 프로그램이 충돌 함
ABAddressBookRef addressBook = ABAddressBookCreate();
NSMutableArray *allPeople = (NSMutableArray*)ABAddressBookCopyArrayOfAllPeople(addressBook);
int nPeople = ABAddressBookGetPersonCount(addressBook);
CFRelease(addressBook);
for(int i=0; i < nPeople; i++){
ABRecordRef person = [allPeople objectAtIndex:i];
NSString *name = @"";
CFTypeRef fName = ABRecordCopyValue(person, kABPersonFirstNameProperty);
CFTypeRef lName = ABRecordCopyValue(person, kABPersonLastNameProperty);
ABMultiValueRef multi = ABRecordCopyValue(person , kABPersonPhoneProperty);
NSString *number = (NSString *)ABMultiValueCopyValueAtIndex(multi, 0);
if ([number length] > 0) {
if(fName != NULL)
{
if (lName != NULL) {
name = [[NSString stringWithFormat:@"%@", fName] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
}
else {
name = [[NSString stringWithFormat:@"%@", fName] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
}
NSLog(@"Number==>%@ ",number);
}
}
if (fName != NULL) {
CFRelease(fName);
}
if (lName != NULL) {
CFRelease(lName);
}
if (multi != NULL) {
CFRelease(multi);
}
}
[allPeople release];
나는이 오류를 알아낼 수 없습니다. 나는 또한 모든 것을 공개하고 있는데 그때도 원활하게 돌아 가지 않습니다. 구축하고
ABMultiValueRef multi = ABRecordCopyValue(person , kABPersonPhoneProperty);
NSLog(@"Number===>%d" , ABMultiValueGetCount(multi));
이 와서 나를 도와주세요 코드 부분에 대한 분석 실행할 때
난 메모리 누수의 가능성을 얻고있다.
어떤 종류의 도움이라도 대단히 감사하겠습니다.
미리 감사드립니다.
충돌 로그를 넣을 수 있습니까? 여기 사람들에게 아주 명확한 아이디어를 줄 것이며, 도움을받을 수 있습니다. –
최악의 부분은 경고 나 메시지없이 앱이 충돌합니다. – devsri
@devsri : 사용자에게 알리지 않고 충돌하는 것은 Apple의 방식입니다. – MusiGenesis