2

i am developing a application in which i add contact to contact List. i am able to basic info like name, address, email, phone, notes etc. but i want to add some custom field like userLabel1, userValue1 , bioPersonal, bioWork, bioOther. so i want to add custom fields to address Book'contacts.

whether it is possible to add custom field to contact? if yes , then please suggest any link or sample code?

F'x
  • 12,105
  • 7
  • 71
  • 123
Rupesh
  • 7,866
  • 11
  • 41
  • 58

2 Answers2

4

Basically, there is no way to do that. Address Book doesn't let you add custom fields. However, what you can do is put your data in the "Notes" field for each contact. That will, however, look weird in apps other than yours.

F'x
  • 12,105
  • 7
  • 71
  • 123
  • hi, i already use the notes field to store notes information. ok one more thing . whether is it possible to hide the field like suffix, nickName etc. Idea is that store some value in these field and when user see the contacts, then these field is not visible – Rupesh Feb 13 '10 at 11:26
  • @Rupesh: I had to do lots of customization of contacts in an app I did recently. The short answer is that there is no way to do it. I had to write my own contact view controller. – Daniel T. Apr 22 '11 at 23:06
0
    let store = CNContactStore()

    // phoneNumberToEdit is the CNContact which you need to update
    guard var mutableCont = phoneNumberToEdit?.mutableCopy() as? CNMutableContact else  { return }
    let phoneNumber = CNPhoneNumber(stringValue: "0123456789")
    var currentContact = CNLabeledValue(label: "MyCustomLabel", value: phoneNumber)
    mutableCont.phoneNumbers = [currentContact]

    let request2 = CNSaveRequest()
    request2.update(mutableCont)
    do{
    try store.execute(request2)
    } catch let error{
    print(error)
    }
K Ravi Kumar
  • 71
  • 1
  • 2