Consider some typical CF code involving error handling, say something like this:
ABRecordRef aRecord = ABPersonCreate();
CFErrorRef anError = NULL;
ABRecordSetValue(aRecord, kABPersonFirstNameProperty, CFSTR("Joe"), &anError);
How do I handle anError
after this code? Do I have to retain it, to make sure it doesn't go away, and then later release it? Or am I already the owner and I only have to release it later?
According to "CFError.h" where CFErrorRef is defined: i.e.
if you scroll to the top, you will see this in line 14 to line 22:
Thus it seems like we do need to release the CFErrorRef ourselves!
In the Core Foundation framework, it's always the caller's responsibility to release an error returned through a
CFErrorRef *
argument. For example here's a header file comment fromCFBundle.h
:Chances are the AB framework uses the same convention.