This is my code to get the device's Contacts and save to MutableArray
.
But I need to get the recordID
for all contacts individually and save into the same Array for further use. (For example, to delete Contacts using recordId
).
Please help me, I'm stuck for 4 days on that.
[contactStore enumerateContactsWithFetchRequest:request error:nil usingBlock:^(CNContact* __nonnull contact, BOOL* __nonnull stop){
if( contact.phoneNumbers)
phoneNumber = [[[contact.phoneNumbers firstObject] value]];
if( contact.emailAddresses)
emailAddress = [[contact.emailAddresses firstObject] value];
contactValue=[[NSMutableDictionary alloc] init];
[contactValue setValue:phoneNumber ?:@"" forKey:@"phoneNumber"];
[contactValue setValue:emailAddress ?:@"" forKey:@"emailAddress"];
[contactValue setObject:contact.identifier forKey:@"phoneIdentifier"];
[contactValue setObject:contact.givenName ?:@"" forKey:@"firstName"];
[contactValue setObject:contact.familyName ?:@"" forKey:@"lastName"];
[_totalContact addObject:contactValue];
}]