0

I have a User model item, and I want to use this User information to create a contact that can be shared through a UIActivityController. This is currently not possible because the properties of CNContacts are read-only:

if let name = user?.firstName {
    contact.givenName = name
}

if let lastName = user?.lastName {
    contact.familyName = lastName
}

if let companyRole = user?.companyRole {
    contact.jobTitle = companyRole
}

if let company = user?.company {
    contact.organizationName = company
}

Is it possible to create a contact? I don't see any constructs/initializers that allow me to create one.

Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223
Cesare
  • 9,139
  • 16
  • 78
  • 130

1 Answers1

1

You should work with a CNMutableContact instead of a CNContact. That way, the properties will be modifiable.

Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223