Reputation: 12465
I hit this weird problem when implementing ABPeoplePickerNavigationControllerDelegate. So identifier sometime was got its value incorrectly in delegate method
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier;
For example when I chose the first number from a contact, identifier should be 0. But sometime it was 1 (even when that contact only has 1 number)!!
It is easy to verify that,
...
ABMultiValueRef phoneProperty = ABRecordCopyValue(person,property);
int count = ABMultiValueGetCount(phoneProperty);
NSLog(@"How many numbers do I have %d and which number do I choose %d",count,identifier);
And it printed out this sometime
How many numbers do I have 1 and which number do I choose 1
so has anyone hit the same problem as well ?
Update: sometime identifier is even bigger than count. How come!!
How many numbers do I have 2 and which number do I choose 3
Upvotes: 2
Views: 848
Reputation: 12465
Just figured out why and feel embarrassed of myself.
So ABMultiValueIdentifier is different than index, after I got identifier I need to use ABMultiValueGetIndexForIdentifier to get the index. Then using that index to call ABMultiValueCopyValueAtIndex.
BTW, there was a same question at AdressBook Crash, only with some contacts!
Upvotes: 3