Friday, March 25, 2011

Assertion failed: (((ABCMultiValue *)multiValue)->flags.isMutable), function ABMultiValueAddValueAndLabel

I Had this code

ABMultiValueRef multiPhone = ABRecordCopyValue(person, kABPersonPhoneProperty);
// here y was getting the error: Assertion failed: (((ABCMultiValue *)multiValue)->flags.isMutable), //function ABMultiValueAddValueAndLabel
ABMultiValueAddValueAndLabel(multiPhone, @"1111111111", kABOtherLabel ,NULL);

It was because, in order to add some values to multiPhones var, this had to be mutable, it means to be ABMutableMultiValueRef type, so:

ABMultiValueRef multiPhones = ABRecordCopyValue(person, kABPersonPhoneProperty);
ABMutableMultiValueRef multiPhone = ABMultiValueCreateMutableCopy(multiPhones);
ABMultiValueAddValueAndLabel(multiPhone, @"1111111111", kABOtherLabel ,NULL);

that's all.









3 comments:

Anonymous said...

Thanks a lot !

jhonjairoroa87 said...

That's great. I'm glad It could help you.

Unknown said...

This post save my day. Thanks a lot!