FROM : Alec Carlson
DATE : Sat Nov 09 20:55:42 2002
I'll assume that you actually have a valid ABPersonRef... This code snippet
will get you what you want:
int indx;
int numItems;
CFStringRef UserData;
CFStringRef workNumber = nil;
CFStringRef homeNumber = nil;
ABPersonRef aPerson;
ABMultiValueRef aPersonsPhoneNumbers;
// Get the ABPersonRef for this user
aPerson = DestinationList[item].addressBook.person;
// Get the list of phone numbers for this person
if( (aPersonsPhoneNumbers = (ABMultiValueRef)ABRecordCopyValue( aPerson,
kABPhoneProperty )) == nil )
return CFSTR("");
// How many phone numbers are there ?
numItems = ABMultiValueCount( aPersonsPhoneNumbers );
// Get the Work & Home Phone Numbers - stop if both number have been found
for( indx = 0; (indx < numItems) && !workNumber && !homeNumber; ++indx )
{
UserData = ABMultiValueCopyLabelAtIndex( aPersonsPhoneNumbers, indx );
if( !workNumber && CFStringCompare( UserData, kABPhoneWorkLabel, 0 )
== kCFCompareEqualTo )
workNumber = (CFStringRef)ABMultiValueCopyValueAtIndex(
aPersonsPhoneNumbers, indx );
else if( !homeNumber && CFStringCompare(UserData,kABPhoneHomeLabel,0 )
== kCFCompareEqualTo )
homeNumber = (CFStringRef)ABMultiValueCopyValueAtIndex(
aPersonsPhoneNumbers, indx );
}
Alec
on 11/8/02 3:46 PM, T G at <email_removed> wrote:
> Hi all,
>
> I'm having trouble with phone numbers & the AddressBook. Specifically, when
> I try to retreive the phone numbers for a given person, I get no data,
> regardless of the fact that the contact in question definitely has at least
> one phone number.
>
> Here's how I'm doing it... (where person is of type ABPerson *)
>
> ABMutableMultiValue *phone;
> //...
> phone = [person valueForProperty:kABPhoneProperty];
> //...
>
> phone is always nil. :(
>
> Has anyone else encountered this? Or is it just something really basic that
> I've managed to overlook?
>
> Thanks,
>
> Terence
>
>
> _________________________________________________________________
> Add photos to your e-mail with MSN 8. Get 2 months FREE*.
> http://join.msn.com/?page=features/featuredemail
> _______________________________________________
> cocoa-dev mailing list | <email_removed>
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
> Do not post admin requests to the list. They will be ignored.
>
-----------------------------------------------------------------------
Time is Short and the Water Rises
-----------------------------------------------------------------------
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
DATE : Sat Nov 09 20:55:42 2002
I'll assume that you actually have a valid ABPersonRef... This code snippet
will get you what you want:
int indx;
int numItems;
CFStringRef UserData;
CFStringRef workNumber = nil;
CFStringRef homeNumber = nil;
ABPersonRef aPerson;
ABMultiValueRef aPersonsPhoneNumbers;
// Get the ABPersonRef for this user
aPerson = DestinationList[item].addressBook.person;
// Get the list of phone numbers for this person
if( (aPersonsPhoneNumbers = (ABMultiValueRef)ABRecordCopyValue( aPerson,
kABPhoneProperty )) == nil )
return CFSTR("");
// How many phone numbers are there ?
numItems = ABMultiValueCount( aPersonsPhoneNumbers );
// Get the Work & Home Phone Numbers - stop if both number have been found
for( indx = 0; (indx < numItems) && !workNumber && !homeNumber; ++indx )
{
UserData = ABMultiValueCopyLabelAtIndex( aPersonsPhoneNumbers, indx );
if( !workNumber && CFStringCompare( UserData, kABPhoneWorkLabel, 0 )
== kCFCompareEqualTo )
workNumber = (CFStringRef)ABMultiValueCopyValueAtIndex(
aPersonsPhoneNumbers, indx );
else if( !homeNumber && CFStringCompare(UserData,kABPhoneHomeLabel,0 )
== kCFCompareEqualTo )
homeNumber = (CFStringRef)ABMultiValueCopyValueAtIndex(
aPersonsPhoneNumbers, indx );
}
Alec
on 11/8/02 3:46 PM, T G at <email_removed> wrote:
> Hi all,
>
> I'm having trouble with phone numbers & the AddressBook. Specifically, when
> I try to retreive the phone numbers for a given person, I get no data,
> regardless of the fact that the contact in question definitely has at least
> one phone number.
>
> Here's how I'm doing it... (where person is of type ABPerson *)
>
> ABMutableMultiValue *phone;
> //...
> phone = [person valueForProperty:kABPhoneProperty];
> //...
>
> phone is always nil. :(
>
> Has anyone else encountered this? Or is it just something really basic that
> I've managed to overlook?
>
> Thanks,
>
> Terence
>
>
> _________________________________________________________________
> Add photos to your e-mail with MSN 8. Get 2 months FREE*.
> http://join.msn.com/?page=features/featuredemail
> _______________________________________________
> cocoa-dev mailing list | <email_removed>
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
> Do not post admin requests to the list. They will be ignored.
>
-----------------------------------------------------------------------
Time is Short and the Water Rises
-----------------------------------------------------------------------
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
| Related mails | Author | Date |
|---|---|---|
| T G | Nov 8, 22:46 | |
| Barry Books | Nov 9, 15:13 | |
| Henri Lamiraux | Nov 9, 16:36 | |
| Alec Carlson | Nov 9, 20:55 | |
| Steve Sheets | Nov 9, 22:02 | |
| Sheehan Olver | Nov 9, 22:03 |






Cocoa mail archive

