Helpful Addition to ABPerson

I hope I beat everyone else to the punchline (see here for reference). The original version of the code I posted didn't actually, you know... work. I spent a ridiculous amount of debugging it (labels are not identifiers!). Maybe this will actually help somebody who's building MotherFinder 1.0.

@interface ABPerson (CanIBuyAVowel)
- (id)yoMomma;
@end

@implementation ABPerson (CanIBuyAVowel)
- (id)yoMomma
{
  ABMultiValue * relatives;
  relatives = [self valueForProperty:kABRelatedNamesProperty];

  int i, count = [relatives count];
  NSString * label  = nil;
  NSString * mother = nil;

  for ( i = 0; i < count; i ++ )
  {
    label = [relatives labelAtIndex:i];
    if ([label isEqualToString:kABMotherLabel])
    {
      mother = [relatives valueAtIndex:i];
      break;
    }
  }

  return mother;
}
@end


By the way, I like the signature for setMe in ABAddressBook.h.

- (void)setMe:(ABPerson *)moi;
    // Sets "Me" to moi.
    // Pass nil to clear "Me"


If somebody does decide to make MotherFinder, please adorn the UI with some useless doily eyecandy or something.
Design Element
Helpful Addition to ABPerson
Posted Nov 23, 2006 — 1 comments below




 

Chris Forsythe — Nov 27, 06 2493

I think I can actually use this code Scott, thanks for fleshing it out.

Chris




 

Comments Temporarily Disabled

I had to temporarily disable comments due to spam. I'll re-enable them soon.





Copyright © Scott Stevenson 2004-2015