0

In my application I have to get the record form the AddressBook and after changing some information I wants to save it. This logic in not working in Lion, though it is perfectly working fine in Snow Leopard. 

Code Example:

  ABPerson   *aPerson   = (ABPerson *) [records  objectAtIndex:0];

    [aPerson   setValue:@"Rambo"  forProperty:kABFirstNameProperty]; 

    [[ABAddressBook   sharedAddressBook ]   addRecord:  aPerson];
     
    if([[ABAddressBook sharedAddressBook ]hasUnsavedChanges])
    {
         [[ABAddressBook sharedAddressBook] save];
    }

If condition is returing NO, it means address book do not have any unsaved changes, but I have just added a contact.

Please any body tell me what I am doing wrong? or what I need to do different in Lion.

Thanks.

pad
  • 41,040
  • 7
  • 92
  • 166
rambo
  • 61
  • 8

1 Answers1

1

Are you trying to change an existing person's name to Rambo, or add a new one? I think your code seems to be half of each. If you are changing an existing person, then you don't need line 3. If you're adding a new person then line 1 should be

ABPerson *aPerson = [[ABPerson alloc] init];
AlexT
  • 596
  • 7
  • 15