Re: AddressBook - ABMultiValue
Re: AddressBook - ABMultiValue
- Subject: Re: AddressBook - ABMultiValue
- From: Henri Lamiraux <email@hidden>
- Date: Tue, 27 Aug 2002 17:26:47 -0700
kABPhoneMainLabel is not an identifier but a Label. The identifier in a
ABMultiValue is basically the "index" of a specific value. We cannot
use a real index (0, 1, 2,...) because lets says you app for some
reason needs to remember a specific phone number (like phone at index
1). Another app add, remove or replace a bunch of phone numbers. Your
index of 1 know doesn't point to the same phone number at all.
Identifier in a multivalue will always point to the same entry (unless
the entry is gone and then you get nil for -valueForIdentifier:)
We have a request for a -valuesForLabel: type of API for ABMultiValue.
It is easy to implement. But remember that in AddressBook you can have
multiple values with the same label (like 2 work phone, 2 home phone,
etc...) so -valuesForLabel needs to return an array
// I did not compile this code so....
@implementation ABMultiValue(MyAppMultiValueAdditions)
- (NSArray *)valuesForLabel:(NSString *)label
{
NSMutableArray *array;
int i, count;
array = [NSMutableArray array];
count = [self count];
for (i = 0; i < count; i++) {
if ([[self labelAtIndex:i] isEqualToString:label]) {
[array addObject:[self valueAtIndex:i]];
}
}
return array;
}
@end
On Monday, August 26, 2002, at 11:08 PM, Ben Mackin wrote:
I have been working on adding Address Book support (10.2) to my app and
everything is going great, except for one thing. I have been reading
about
this whole ABMultiValue thing, and thought I had gotten it. But when I
try
and use the following code:
ABMultiValue *myValues;
int myIndex;
myValues = [[peopleFound objectAtIndex:0]
valueForProperty:kABPhoneProperty];
myIndex = [myValues indexForIdentifier:kABPhoneMainLabel];
string = [myValues valueAtIndex: myIndex];
I get an error that:
-[NSCFArray objectAtIndex:]: index (2147483647) beyond bounds (2)
So when I am supposed to supply an identifier, is it not supposed to
be one
from ABGlobals.h? I know there is a value in the address book for
kABPhoneMainLabel, and another in the phone tree (the fax number) so I
think
something should be returned.
I have read through the manual (page) on this, and from my
understanding
this should work, right?
Thanks,
Ben
_______________________________________________
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.
Henri Lamiraux
Engineering Manager
User Interface Tools Group
Apple
_______________________________________________
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.