Re: AddressBook - ABMultiValue
Re: AddressBook - ABMultiValue
- Subject: Re: AddressBook - ABMultiValue
- From: Andy Lee <email@hidden>
- Date: Tue, 27 Aug 2002 15:48:22 -0400
On Tuesday, August 27, 2002, at 02:08 AM, Ben Mackin wrote:
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)
The problem is that myIndex is getting a value of -1, meaning the
identifier kABPhoneMainLabel was not found in myValues. But
-objectAtIndex: takes an unsigned integer, so when it sees the bit
pattern for -1, it interprets it as 2147483647.
You could work around this with something like:
myIndex = [myValues indexForIdentifier:kABPhoneMainLabel];
if (myIndex >= 0)
{
string = [myValues valueAtIndex:myIndex];
}
else
{
string = nil;
}
--Andy
_______________________________________________
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.