I have a memory management problem that i can’t seem to find a solution for. The code is as follow:
-(ABRecordRef)convertABCPerson:(ABCPerson*) person{
// create new address book person record
ABRecordRef aRecord = ABPersonCreate();
[self setValuesFor:person toARecord:aRecord];
return aRecord;
}
So i convert my own class to a ABRecordRef and now I need somehow to “autorelease” this object(So i can take ownership in a different object). I am using ARC and a ABRecordRef cannot be toll-bridged to a Cocoa foundation class. Any ideas how i could solve this memory management issue ?
Thanks for the help 🙂
I found a solution to my problem. The only thing i had to do is cast it to id and using bridge transfer to let ARC handle the memory management. From an other class you can do a ABRecordRef cast as __bridge so that ARC handles the record correctly.
The solution:
The casting back: