Assertion failure ABPerson

  • I found other posts at various discussion sites indicating a bug with
    this when using vCardData, but nothing for this.  I am trying to
    programmatically load ABPerson records to the logged in user's AB.
    The exception is raised while executing this:

        if ([abKey isEqualToString:kABEmailProperty] || [abKey
    isEqualToString:kABPhoneProperty]) {
          [person setValue:[NSArray arrayWithObject:col] forKey:abKey];
        }else{
          [person setValue:col forKey:abKey];
        }

    Several values are successfully loaded, like first/last name, before
    loading an email value spews this:

    2007-09-12 00:00:11.381 AddressBookImporter[11891] *** Assertion
    failure in -[ABPerson
    nts_SetValue:forProperty:recordCouldBeInDatabase:], Framework/
    AddressBook/ABRecord.m:515

    Any thoughts?

    --Brian
  • On 12.09.2007, at 06:17, Anthony Arthur wrote:
    > if ([abKey isEqualToString:kABEmailProperty] || [abKey
    > isEqualToString:kABPhoneProperty]) {
    > [person setValue:[NSArray arrayWithObject:col] forKey:abKey];
    > }else{
    > [person setValue:col forKey:abKey];
    > }

      Have you set a breakpoint in which of the two cases it's failing?
    Only in one, both? Have you checked the docs? I vaguely remember that
    Address book has ABMultiValue and similar classes, so are you sure
    this should be an NSArray, and not some ABxxx class? What is "col"?
    Have you NSLogged its class to see if it is the class you expect?

    Cheers,
    -- M. Uli Kusterer
    http://www.zathras.de
  • You are right, it is supposed to be an instance of ABMultiValue,
    which was clear to me.  I'm new to this framework, just started
    reading up on it yesterday, and I kept imagining ABMultiValue as an
    array.  That's why I sort of blindly implemented it that way, now it
    is obvious what I did wrong.

    Thanks,

    --Brian

    On Sep 12, 2007, at 9:06 AM, Uli Kusterer wrote:

    >
    > On 12.09.2007, at 06:17, Anthony Arthur wrote:
    >> if ([abKey isEqualToString:kABEmailProperty] || [abKey
    >> isEqualToString:kABPhoneProperty]) {
    >> [person setValue:[NSArray arrayWithObject:col] forKey:abKey];
    >> }else{
    >> [person setValue:col forKey:abKey];
    >> }
    >
    > Have you set a breakpoint in which of the two cases it's failing?
    > Only in one, both? Have you checked the docs? I vaguely remember
    > that Address book has ABMultiValue and similar classes, so are you
    > sure this should be an NSArray, and not some ABxxx class? What is
    > "col"? Have you NSLogged its class to see if it is the class you
    > expect?
    >
    > Cheers,
    > -- M. Uli Kusterer
    > http://www.zathras.de
    >
    >
previous month september 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Go to today