2012-04-25 18 views
2

我在实现ABPeoplePickerNavigationControllerDelegate时遇到了这个奇怪的问题。所以标识符有时被得到了它的值不正确地在委托方法ABMultiValueIdentifier在ABPeoplePickerNavigationControllerDelegate中是否设置错误?

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier; 

例如,当我选择从一个相接触的第一数量,标识符应当是0。可是,有时候它是1(即使当接触仅具有1号) !

这是很容易验证,

... 
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); 

它打印出来,这一段

多少个数字我有和数量如何选择

有没有人碰到同样的问题?

更新:有时标识符比count更大。怎么来的!!

多少个数字我有2和数量做我选择3

回答

3

就想通了,为什么而感到尴尬自己。

所以ABMultiValueIdentifier不同于索引,在得到标识符后我需要使用ABMultiValueGetIndexForIdentifier来获取索引。然后使用该索引来调用ABMultiValueCopyValueAtIndex。

顺便说一句,有同样的问题在AdressBook Crash, only with some contacts!

相关问题