Trying to get an NSData object with the vCard representation of the contact By using below interface.
+ (NSData *)dataWithContacts:(NSArray *)contacts
error:(NSError * _Nullable *)error
Got an NSData Object when passed one CNContact to that above interface. Here is the working code
CNMutableContact * contact = [CNMutableContact new];
contact.middleName = @"Stalin";
contact.contactType = CNContactTypePerson;
contact.givenName = @"Gates";
contact.familyName = @"GemmyApps";
NSData *bufferedData = [CNContactVCardSerialization dataWithContacts:contact error:nil];
Unable to get an NSData Object when passed NSArray of CNContacts to that above interface. Here is the code
CNContactStore* contactStore = [[CNContactStore alloc]init];
NSArray * keysToFetch =@[CNContactEmailAddressesKey, CNContactPhoneNumbersKey, CNContactFamilyNameKey, CNContactGivenNameKey, CNContactPostalAddressesKey];
NSMutableArray *arrFetchedcontact = [contactStore unifiedContactsMatchingPredicate:[CNContact predicateForContactsInContainerWithIdentifier: @[contactStore.defaultContainerIdentifier][0]] keysToFetch:keysToFetch error:nil];
NSData *bufferedData = [CNContactVCardSerialization dataWithContacts:arrFetchedcontact error:nil];
lldb Message : Exception writing contacts to vCard (data): A property was not requested when contact was fetched.