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 22, 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




 

Add Your Thoughts

Use UBB tags: [b] [i] [url] [code], and so on
Use [i] for quoting: [i]Quoted Text[/i]
Omit double quotes in links: [url=http://apple.com]Apple[/url]
Accented characters are currently stripped from names



Please enter the company who makes the Mac:
this is an anti-spam measure
Some comments may be edited for formatting, or removed if too far off-topic.




Technorati Profile
Copyright © Scott Stevenson 2004-2008