In my swift app, I am retrieving AddressBook contacts from AddressBook framework. Contacts are retrieved successfully except the following case.
Case 1:
If I save a contact number alone without contact name to AddressBook, contact is successfully added.
But, If I try to retrieve that contact which does not having name, App crashes, saying that fatal error received.
Coding:
var contactName: String = ABRecordCopyCompositeName(addressBookRecord).takeRetainedValue() as NSString as String
I don't know how to handle this null value exception. Kindly guide me, how to solve this.
This code will not crash if you got any contact without name:
Original post: App crashing while fetching contact numbers from iPhone in SWIFT