tags:

views:

161

answers:

0

I created a method to return the name of an entry in the address book when given an id

   + (id) nameWithRecordID: (ABRecordID) recordID
    {
        ABAddressBookRef addressBook = ABAddressBookCreate();
        ABRecordRef contactrec = ABAddressBookGetPersonWithRecordID(addressBook, recordID);
        .....read the name out
        CFRelease(contactrec);
        CFRelease(addressbook); <------------this is the problematic line
        return name;
    }

It turned out that if I release the addressbook it causes my program to crash RANDOMLY. But if I leave it out it works, but should I really be creating the addressbook each time I get a name?