Questions tagged [cncontact]

CNContact is a thread-safe class for Apple architectures (MacOS, iOS, watchOS, etc.) that represent an immutable value object for contact properties, such as the first name and phone numbers of a contact.

The contact class (CNContact) is a thread-safe, immutable value object of contact properties, such as the contact’s name, image, or phone numbers. The contact class is like NSDictionary; it has a mutable subclass CNMutableContact you can use to modify contact properties. For contact properties that can have multiple values, such as phone numbers or email addresses, an array of CNLabeledValue objects is used. The labeled value class is a thread-safe, immutable tuple of labels and values. Labels describe each value to the user, allowing differentiation such as home and work phone numbers. The Contacts framework provides some predefined labels and you can create your own custom labels.

256 questions
0
votes
1 answer

app crashes in the middle of printing contact names and numbers

This is my code, my app crashes in the middle of printing the data, without an error message in the log. it prints almost 30 people and then crashes, with this message on the line of code that crashed: Thread 1: EXC_BREAKPOINT (code=1, subcode…
Eyzuky
  • 1,843
  • 2
  • 22
  • 45
0
votes
1 answer

Limit what opens appear while sharing contact

I want to share a contact inside of my application but I only want to let the user do it via Message and Mail. Can I block out all other options on the alert sheet? func shareContacts(contacts: [CNContact]) throws { guard let directoryURL =…
user1079052
  • 3,803
  • 4
  • 30
  • 55
0
votes
1 answer

Search contact as per given string from beginning

I want to search contact. I was able to search contact with matching string from 'contains'. But I want to search contact which start as per given searching string. My code is look like that.. extension ContactViewController : UITextFieldDelegate…
NiravS
  • 1,144
  • 1
  • 12
  • 24
0
votes
1 answer

I am struggling with types in appending data to IOS contacts code below gives an error

I am trying to amend a contact in my IOS app but get type error Value of type '[CNContact]' has no member 'familyName' let updateContact = try contactStore.unifiedContacts(matching: predicate,keysToFetch: toFetch as [CNKeyDescriptor]) …
Jeremy
  • 145
  • 1
  • 2
  • 13
0
votes
2 answers

iOS Objective C: Get user selected phone number from CNContactProperty as a string

My question is basically the same as the question here: iOS Swift: Get user selected phone number from CNContactProperty as a string WHICH HAS BEEN WRONGLY MARKED AS DUPLICATE WITHOUT SOLUTIONS (Reason stated in that post). I desperately want to…
steven
  • 1,237
  • 2
  • 11
  • 13
0
votes
1 answer

CNContactPickerViewController: contact detail back button color

I link a simple project to explain my problem. In simple terms, I have a navigation controller based app with red theme and I have to pick email addresses from my contacts via CNContactPickerViewController. My problem is with back bar button of…
Giorgio
  • 1,973
  • 4
  • 36
  • 51
0
votes
1 answer

Fetch all user's contact phone numbers Swift3/iOS9+

Most of the stuff I'm finding is using AddressBook instead of the new Contacts. I'm trying to get the names and phone numbers of all the user's contacts to display in a tableview on the app. Then take all those numbers into an API that cross…
Tommy K
  • 1,759
  • 3
  • 28
  • 51
0
votes
1 answer

how to update CNContact? Get CNErrorDomain Code=2

I'm trying to update your contacts in the caste controller, all well preserved up to a point, this is when adding new numbers that have CNLabeledValue format. I brought in the console result I get this error CNErrorDomain Code = 2…
Alexander Khitev
  • 6,417
  • 13
  • 59
  • 115
0
votes
0 answers

Fetch all the contacts that has no name associated with it using Swift 3

I want to fetch all contacts stored that has no names on it. The below method helps me to search for all the contacts with string passed. I tried to pass empty string to find all contacts with no name, it didn't work. func fetchContactsWithNoName()…
Warrior
  • 39,156
  • 44
  • 139
  • 214
0
votes
2 answers

How to differentiate the phone numbers after fetching the details from local contact

I am fetching the mobile contacts by using below method -(void)fetchContactsandAuthorization { // Request authorization to Contacts CNContactStore *store = [[CNContactStore alloc] init]; [store…
Madhu
  • 439
  • 2
  • 14
0
votes
1 answer

App freezes when requesting access to addressbook

func getContacts() { let store = CNContactStore() if CNContactStore.authorizationStatus(for: .contacts) == .notDetermined { store.requestAccess(for: .contacts, completionHandler: { (authorized: Bool, error: NSError?) -> Void in …
Chris Mikkelsen
  • 3,987
  • 9
  • 29
  • 41
0
votes
1 answer

Capture GivenName from CNContact

I'm trying to capture the given name of a contact when the user selects that contact from the Contact Picker. Right now I'm using this method func contactPicker(_: CNContactPickerViewController, didSelect: CNContact){ print("Selected…
icekomo
  • 9,328
  • 7
  • 31
  • 59
0
votes
2 answers

Dictionary has optional key

I'm having a array of CNContact and I sort them with this function: for contact in self.contacts { var contactName = contact.organizationName let key: String = String(contactName.characters.first).uppercaseString if let arrayForLetter =…
user1007522
  • 7,858
  • 17
  • 69
  • 113
0
votes
1 answer

Command Failed due to signal: Segmentation Fault 11 -- Xcode 8 Swift 3

After some intense googling and brainstorming, I can't find a solution so let's see if Stack Overflow has the magic solution I need. I am using the Contacts framework to fetch dates from a contact. However, this works well but I need to sort the…
Harish
  • 1,374
  • 17
  • 39
0
votes
1 answer

Removing a CNContact array based on one of its key value

I am a swift newbie and trying to play around with the Contacts framework and have encountered a problem:- I have an array of CNContact called contacts with keys of givenName, familyName and phoneNumbers. I want to filter out certain names that is…
allanae
  • 145
  • 2
  • 12