私がコーディングした限り、25000の連絡先をiPhoneの連絡先に挿入する必要があり、シミュレーターで正常に動作し、これは数分で達成できます。しかし、これを iPhone 4s にインポートすると、3 時間以上かかり、部分的な連絡先のみが保存され、アプリが閉じられます。
アドレス帳に複数のレコードを挿入する簡単な方法を教えてください...
これが私のコードです...
for (int i = 0; i < [contactNameArray count]; i++) {
//Create new person and save to this group
ABRecordRef record = ABPersonCreate();
BOOL isSuccess ;
NSString *firstname = [NSString stringWithFormat:@"%@",[contactNameArray objectAtIndex:i]];
isSuccess = ABRecordSetValue(record, kABPersonFirstNameProperty,(__bridge CFStringRef)firstname, &error);
isSuccess = ABRecordSetValue(record, kABPersonLastNameProperty,CFSTR("Custom Contacts"), &error);
ABMutableMultiValueRef copyOfPhones = ABMultiValueCreateMutable(kABPersonPhoneProperty);
NSString *phonenumber = [NSString stringWithFormat:@"%@",[contactPhoneArray objectAtIndex:i]];
CFTypeRef phone= (__bridge CFStringRef)phonenumber;
ABMultiValueAddValueAndLabel(copyOfPhones, phone,kABPersonPhoneMobileLabel,NULL);
isSuccess = ABRecordSetValue(record, kABPersonPhoneProperty, copyOfPhones, &error);
CFRelease(copyOfPhones);
ABMutableMultiValueRef multiEmail = ABMultiValueCreateMutable(kABMultiStringPropertyType);
NSString *emailid = [NSString stringWithFormat:@"%@",[contactEmailArray objectAtIndex:i]];
CFTypeRef email= (__bridge CFStringRef)emailid;
ABMultiValueAddValueAndLabel(multiEmail, email, kABWorkLabel, NULL);
ABRecordSetValue(record, kABPersonEmailProperty, multiEmail, &error);
CFRelease(multiEmail);
isSuccess = ABAddressBookAddRecord(ab, record, &error);
isSuccess = ABAddressBookSave(ab, &error);
ABGroupAddMember(group, record, &error);
NSLog(@"is success %d", isSuccess);
ABAddressBookSave(ab, &error);
}
前もって感謝します....