0
내 연락처 목록에서 검색하려고하지만이 코드는 앱 스토어에서 새로 실행되거나 TestFlight에서 Im 지금 테스트 할 때 충돌합니다. 앱을 제거하고 실행하면 완벽하게 진행됩니다. 그러나 충돌 로그 상태,이 충돌 TestFlight에서 바로 실행 그것은이 라인에 나는ABRecordCopyValue 다른 값?
BOOL found = NO;
NSString *name;
int i = 0;
NSLog(@"Hay %i", [people count]);
while (!found && i < [people count]) {
ABRecordRef person = (ABRecordRef)[people objectAtIndex:i];
ABMultiValueRef multi = ABRecordCopyValue(person, kABPersonPhoneProperty);
NSLog(@"address: %@", multi);
//Freshly from TestFlight this prints "address: Denis" wich is a contac, executed from Xcode it prints, address: ABMultiValueRef 0x1fb68400 with 1 value(s), so I see here's the problem
if([[(NSMutableString*)ABMultiValueCopyValueAtIndex(multi, 0) componentsSeparatedByCharactersInSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]] componentsJoinedByString:@""]){
NSMutableString *tempPhone = [[NSMutableString alloc]initWithString:[[(NSMutableString*)ABMultiValueCopyValueAtIndex(multi, 0) componentsSeparatedByCharactersInSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]] componentsJoinedByString:@""]];
NSLog(@"telf: %@", tempPhone);
int length = [tempPhone length] - 9;
NSString *tempPhone2;
if(length >= 0){
tempPhone2 = [[NSString alloc]initWithString:[tempPhone substringFromIndex:length]];
}
NSLog(@"el telf: %@ y nombre %@ int %i",tempPhone2, [NSString stringWithFormat:@"%@ %@",ABRecordCopyValue(person, kABPersonFirstNameProperty) ? (NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty) : @"",ABRecordCopyValue(person, kABPersonLastNameProperty) ? (NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty) : @""], i);
if([[key objectForKey:@"phone"] isEqualToString:tempPhone2]){
name = [NSString stringWithFormat:@"%@ %@",ABRecordCopyValue(person, kABPersonFirstNameProperty) ? (NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty) : @"",ABRecordCopyValue(person, kABPersonLastNameProperty) ? (NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty) : @""];
found = YES;
}
}
i++;
}
이 NSLog(@"address: %@", multi);
이 TestFlight에서 때의 신선한 출력 라인에 실패 "주소 : 데니스는"느릅 나무에서 실행, 연락처입니다 Xcode는 "address : ABMultiValueRef 0x1fb68400 with 1 value (s) ..."라는 출력을 Xcode에서 인쇄합니다. 그래서 여기에 문제가 있습니다. 그 차이는 이해가 안되는 것은 왜 다른가, 왜 그런지 말해 줄 수 있습니까?
문제는 멀티의 값이 다르다는 것입니다. 따라서 ABMultiValueRef의 값에 액세스하려고하면 어떤 이유로 올바른 객체를 반환하지 않기 때문에 충돌이 발생합니다. – subharb