I am trying to use the following code to add an email to my contact information to store it on the local device, unfortunately the code is crashing the app. How can I go about fixing this? I can see nothing online in Objective-C
all examples are in Swift
CNLabeledValue *mailtest = [CNLabeledValue labeledValueWithLabel:CNLabelWork value:@"curtis.boylan@gmail.com"];
contact.emailAddresses = mailtest;
emailAddresses
is of type NSArray<CNLabelledValue<NSString *> *>
.
Even though you are only adding a single email address, you must put it in an array to assign to that property.
CNLabeledValue *mailtest = [CNLabeledValue labeledValueWithLabel:CNLabelWork value:@"curtis.boylan@gmail.com"];
contact.emailAddresses = @[mailtest];