連絡先リスト内を検索しようとしていますが、アプリストアから、または現在テストしているようにTestFlightから新たに実行すると、このコードがクラッシュします。アプリをアンインストールして[実行]をクリックすると、完全に機能します。しかし、TestFlightから直接実行すると、クラッシュし、クラッシュログに記載され、iの行で失敗します。
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);
では、Fresh from TestFlight "address:Denis"が連絡先であり、Xcodeから実行されると、 "address:ABMultiValueRef 0x1fb68400 with 1 value(s)..."と出力されるため、ここに問題があります。違い、私が理解していないのは、なぜ違うのかということです。理由を教えていただけますか?