2012-04-25 45 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!

相關問題