There is a more fundamental problem: you are not calling ABAddressBookGetSourceWithRecordID properly. The second parameter that it takes is an int, which indicates the identifier of a particular source entry in your address book. You pass it a constant describing the type of a particular source.
The constant you pass in is kABSourceTypeCardDav is always 4. However, the identifier of an iCloud source record in a user's address book can be something completely different.
What you need to do is list all the sources and test their types, for example:
NSArray *allSources = (NSArray*)ABAddressBookCopyArrayOfAllSources(addressBook); for (int i = 0; i < allSources.count; i++) { ABRecordRef src = [allSources objectAtIndex:i]; NSNumber *stObj = (NSNumber*)ABRecordCopyValue(src, kABSourceTypeProperty); ABSourceType st = (ABSourceType)[stObj intValue]; if (st == kABSourceTypeCardDAV) { int recordID = ABRecordGetRecordID(src); break; } }
Then you can use recordID as an argument for the first function
Danny source share