Reputation: 10196
I'm having this problem with the following address book code (that works great, but definitely leaks):
ABMultiValueRef email = ABRecordCopyValue(person, property);
NSString *type = (__bridge NSString *)(ABMultiValueCopyValueAtIndex(email, 0));
self.textEmail.text = type;
CFRelease(email);
I have already fixed one leak with the CFRelease(email) statement but can't fix this problem:
I can't call [type release] as this is an ARC project and CFRelease((CFTypeRef) type) isn't allowed. How can I release the bridged instance?
Upvotes: 1
Views: 912
Reputation: 4843
Just add this method, instead of CFRelease(email);
if (email) { CFRelease(email); }
Upvotes: 2
Reputation: 8245
Change the __bridge to __bridge_transfer. This will make type be the owner of the reference and thus will be automatically released at end of scope.
Upvotes: 7