• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Ignoring an empty field in the address book
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Ignoring an empty field in the address book


  • Subject: Ignoring an empty field in the address book
  • From: Ben Mackin <email@hidden>
  • Date: Fri, 03 Jan 2003 18:04:47 -0800

I am trying to ignore the last name field if it is empty, but I can't figure
out how to do this.

Here is a snipit of my current code, where peopleFound = [AB
recordsMatchingSearchElement:firstAndLast]:

tempString = [[peopleFound objectAtIndex:i]
valueForProperty:kABFirstNameProperty];
temp2String = [tempString stringByAppendingString:@" "];

if([[[peopleFound objectAtIndex:i] valueForProperty:kABLastNameProperty]
isEqualToString:@""])
{
NSLog(@"No last name");
temp3String = tempString;
}
else
temp3String = [temp2String stringByAppendingString:[[peopleFound
objectAtIndex:i] valueForProperty:kABLastNameProperty]];

And this is what I get when run, and it comes across a record with no last
name:

[NSCFString stringByAppendingString:]: nil string (or other) argument

I know it is the if statement, as I added some more NSLogs and found that
getting the valueForProperty that doesn't exist just raises an exception. So
I looked some more at the ABPerson.h file and found:

+ (NSArray *)properties;
// Returns an array of property names

So I thought I could just scan through the returned properties, and if no
last name property was returned, I can go from there. However, when this
code is run:

NSLog([[[peopleFound objectAtIndex:i] properties] count]);

Just to get the number of properties found, I get:

*** -[ABPerson properties]: selector not recognized

Anyone have some thoughts? All I am trying to do is list all the names in
the address book in a popup menu. But I have run into issues with this
no-last name thing.

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.

  • Follow-Ups:
    • Re: Ignoring an empty field in the address book
      • From: Angela Brett <email@hidden>
  • Prev by Date: Re: NSMutableDictionary Q's
  • Next by Date: Re: NSMutableDictionary Q's
  • Previous by thread: Cannot merge groups (yet) for wid....
  • Next by thread: Re: Ignoring an empty field in the address book
  • Index(es):
    • Date
    • Thread