• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: AddressBook & phone multivalue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AddressBook & phone multivalue


  • Subject: Re: AddressBook & phone multivalue
  • From: Alec Carlson <email@hidden>
  • Date: Sat, 09 Nov 2002 13:55:42 -0600

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@hidden 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@hidden
> 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@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >AddressBook & phone multivalue (From: "T G" <email@hidden>)

  • Prev by Date: Re: Using flex and bison from within a cocoa application ?
  • Next by Date: Re: "weak link" framework refs for 10.1 compatibility?
  • Previous by thread: Re: AddressBook & phone multivalue
  • Next by thread: Re: AddressBook & phone multivalue
  • Index(es):
    • Date
    • Thread