I've got the following class that is a wrapper around an ABPerson (ABRecordRef):
@interface Recipient : NSObject {
ABRecordRef person;
}
- (id)initWithPerson:(ABRecordRef)person;
@end
@implementation
- (id)initWithPerson:(ABRecordRef)_person {
if(self = [super init]) person = CFRetain(_person);
return self;
}
- (void)dealloc {
if(person) CFRelease(person);
[super dealloc];
}
@end
I've left some of the methods out, but they aren't relevant to this question.
Everything works fine, except I get an EXC_BAD_ACCESS
on the if(person) CFRelease(person);
line. Why does this happen? I'm not calling CFRelease or CFRetain at all anywhere else in my app.
Edit, another note: If I add this right before the CFRelease line:
NSLog(@"retain count is %d", CFGetRetainCount(person));
It prints retain count is 1