You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working on a App which Syncs new/existing contacts with the default Address book. To avoid duplicates I am searching for person in the AddressBook and if I get any results I simply update the Person. Furthermore, to avoid duplication of phone numbers and email addresses within the Person I do the following,
//Set phone number if exists
if(user.phone){
RHMultiStringValue *phoneMultiValue = [person phoneNumbers];
RHMutableMultiStringValue *mutablePhoneMultiValue = [phoneMultiValue mutableCopy];
if (! mutablePhoneMultiValue) mutablePhoneMultiValue = [[RHMutableMultiStringValue alloc] initWithType:kABMultiStringPropertyType];
This works great for users that are already in the AddressBook but when I created a new user with,
[RHPerson newPersonInSource:[self.addressBook defaultSource]];
Things get funky!!
[person emails] and [person phoneNumbers] returns an array with pre-populated values from random contacts in the AddressBook even though a new RHPerson was created.
I did manage to workaround it forcing initialization on setting emails and phoneNumbers when a new Person is created as follows,
No idea. Possibly because the created objects are not saved to the store. Feel free to upload a sample project or write a unit-test to exercise the issues you are having and i'll see what i can ascertain.
I am working on a App which Syncs new/existing contacts with the default Address book. To avoid duplicates I am searching for person in the AddressBook and if I get any results I simply update the Person. Furthermore, to avoid duplication of phone numbers and email addresses within the Person I do the following,
//Set phone number if exists
if(user.phone){
RHMultiStringValue *phoneMultiValue = [person phoneNumbers];
RHMutableMultiStringValue *mutablePhoneMultiValue = [phoneMultiValue mutableCopy];
if (! mutablePhoneMultiValue) mutablePhoneMultiValue = [[RHMutableMultiStringValue alloc] initWithType:kABMultiStringPropertyType];
This works great for users that are already in the AddressBook but when I created a new user with,
[RHPerson newPersonInSource:[self.addressBook defaultSource]];
Things get funky!!
[person emails] and [person phoneNumbers] returns an array with pre-populated values from random contacts in the AddressBook even though a new RHPerson was created.
I did manage to workaround it forcing initialization on setting emails and phoneNumbers when a new Person is created as follows,
person.emails = [[RHMultiStringValue alloc] init];
person.phoneNumbers = [[RHMultiStringValue alloc] init];
This fixed my issue but would like to dig deep as to why this is happening.
The text was updated successfully, but these errors were encountered: