i'm studying iOS programming.
i wrote code that associated an address.
there's so many methods. like
i'm dividing a group.
here's group1
ABAddressBookCreate();
ABRecordCopyCompositeName(argument);
ABRecordCopyValue(argument1, argument2);
ABRecordCopyValue(argument1, argument2);
ABMultiValueCopyLabelAtIndex(argument1, argument2);
ABMultiValueCopyValueAtIndex(argument1, argument2);
and another one is right here, group2
CFArrayGetCount(argument);
CFArrayGetValueAtIndex(argument1, argument2);
ABMultiValueGetCount(argument);
i know there's so many other methods.
but i wonder when i use CFRelease method.
i think group2's all methods don't do CFRelease
because that contain the word "Get", not allocated.
and i think group1's all method have to use CFRelease
because there's a string "copy".
i have a book.
but there's used CFRelease twice.
one is release ABAddressBookCreate()
another one is ABAddressBookCopyPeopleWithName.
all of other things don't use CFRelease.
so i wonder when i use CFRelease.
please tell me when i use CFRelease.
If the function name contains "Copy" or "Create", then you own the object, so you must release it when you finish your work with it. This is called "The Create Rule". For more information on Memory management for Core Foundation, you can refer to Memory Management Programming Guide for Core Foundation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With