Re: AddressBook, ABMultiValue, and indexForIdentifier
Re: AddressBook, ABMultiValue, and indexForIdentifier
- Subject: Re: AddressBook, ABMultiValue, and indexForIdentifier
- From: Andrew Salamon <email@hidden>
- Date: Wed, 27 Nov 2002 07:41:18 -0800
I think the problem is that you are confusing labels and identifiers.
kABPhoneHomeLabel is a label, but you are trying to use it as an
identifier. kABPhoneHomeLabel looks something like this:
"_$!<Home>!$_", but identifiers look like:
"3C9E50C5-F103-11D6-9218-003065BADDAE".
I think what you are going to have to do is loop through all of the
phone numbers and compare the label of each one (using - (NSString
*)labelAtIndex:(int)index;) to kABPhoneHomeLabel.
This seems to work:
ABPerson *theRecord;
// Find a particular person record...
int index;
ABMultiValue *mValue = [theRecord
valueForProperty:kABPhoneProperty];
NSLog( @"Home Label: %@", kABPhoneHomeLabel );
NSLog( @"Work Label: %@", kABPhoneWorkLabel );
NSLog( [mValue description] );
for( index = [mValue count]-1; index >= 0; --index )
{
id value = [mValue valueAtIndex:index];
NSLog( @"Index: %d Label: %@", index, [mValue
labelAtIndex:index] );
NSLog( [value description] );
}
Andrew
On Tuesday, November 26, 2002, at 06:00 PM, Terence G4 Mac wrote:
Hi all,
I'm experiencing some wierdness with the Address Book's
indexForIdentifier on ABMultiValue fields.
Specifically, there are cases where a contact entry clearly has, for
example, a home phone. Yet, when I query the ABMultiValue field for
the indexForIdentifier for the kABPhoneHomeLabel, I won't get a valid
result.
Or, with code...
//...
ABMutableMultiValue *phone;
phone = [[person valueForProperty:kABPhoneProperty] mutableCopy];
if ([phone count] > 1)
{
i = [phone indexForIdentifier:kABPhoneHomeLabel];
if ((i > 0) && (i < 12))
[self setHome_phone1: [phone valueAtIndex:i]]; //never gets
here
//....
}
The net result being that I never get a home phone value back, even if
there's one to get...
So, can anyone spot what I'm doing wrong? Is it the fact that I access
the mutableCopy instead of the valueForProperty directly?
Any thoughts would be greatly appreciated :)
Thanks!!
Terence
_______________________________________________
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.