Re: AddressBook - ABMultiValue
Re: AddressBook - ABMultiValue
- Subject: Re: AddressBook - ABMultiValue
- From: Andy Lee <email@hidden>
- Date: Tue, 27 Aug 2002 18:43:16 -0400
At 2:20 PM -0700 8/27/02, Ben Mackin wrote:
> You could work around this with something like:
> myIndex = [myValues indexForIdentifier:kABPhoneMainLabel];
if (myIndex >= 0)
{
string = [myValues valueAtIndex:myIndex];
}
else
{
string = nil;
}
If I am reading you correctly, this would only be helpful if there was no
address book entry for the main phone number (or whatever I am checking).
Right, it's defensive programming to handle cases where the phone
number (or whatever) is not present. Maybe in your case you can be
sure it will, but in the general case you can't. Instead of "string
= nil;" you could maybe log a warning message. At least you wouldn't
be throwing an array exception.
My main point was to explain the out-of-bounds exception, which
seemed to be confusing a couple of other folks. As for why
-indexForIdentifier: didn't return what you expected, I can only
suggest plain old low-level debugging. Step through in the debugger
and see what the values of things are at each step. Do an NSLog of
myValues and of kABPhoneMainLabel. Things like that. A tiny bit of
brute force goes a long way in uncovering this type of problem.
--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.