I want to create an array of ABRecordRef(s) to store contacts which have a valid birthday field.
NSMutableArray* bContacts = [[NSMutableArray alloc] init
Create an NSObject wich store your ABRecordRef like this :
// ABContact.h
@interface ABContact : NSObject
{
ABRecordRef _record;
}
@property (nonatomic, readonly) NSDate *birthday;
- (id)initWithRecord:(ABRecordRef)aRecord;
@end
// ABContact.m
@implementation ABContact
#pragma mark - Init
- (id)initWithRecord:(ABRecordRef)aRecord;
{
if ((self = [super init]))
_record = CFRetain(aRecord);
return self;
}
#pragma mark - Getter
- (NSDate *)birthday
{
return (NSDate *)ABRecordCopyValue(record, kABPersonBirthdayProperty) autorelease];
}
#pragma mark - Memory management
- (void)dealloc
{
CFRelease(_record);
[super dealloc];
}
@end
You should take a look at the Erica Sadum library the author of the iPhone cookbook. Here is the code wich inspire this code -> url