diff --git a/Pod/Core/Private/Builders/APContactBuilder.m b/Pod/Core/Private/Builders/APContactBuilder.m index 9e74ac3..34e3530 100644 --- a/Pod/Core/Private/Builders/APContactBuilder.m +++ b/Pod/Core/Private/Builders/APContactBuilder.m @@ -65,6 +65,10 @@ - (APContact *)contactWithRecordRef:(ABRecordRef)recordRef fieldMask:(APContactF { contact.birthday = [self.extractor dateProperty:kABPersonBirthdayProperty]; } + if (fieldMask & APContactFieldDates) + { + contact.dates = [self.extractor dates]; + } if (fieldMask & APContactFieldWebsites) { contact.websites = [self.extractor arrayProperty:kABPersonURLProperty]; diff --git a/Pod/Core/Private/Extractors/APContactDataExtractor.h b/Pod/Core/Private/Extractors/APContactDataExtractor.h index ce76dbd..f2e5f26 100644 --- a/Pod/Core/Private/Extractors/APContactDataExtractor.h +++ b/Pod/Core/Private/Extractors/APContactDataExtractor.h @@ -27,6 +27,7 @@ - (NSArray *)socialProfiles; - (NSArray *)relatedPersons; - (NSArray *)linkedRecordIDs; +- (NSArray *)dates; - (APSource *)source; - (APRecordDate *)recordDate; - (NSString *)stringProperty:(ABPropertyID)property; diff --git a/Pod/Core/Private/Extractors/APContactDataExtractor.m b/Pod/Core/Private/Extractors/APContactDataExtractor.m index 2338266..7bc2ad7 100644 --- a/Pod/Core/Private/Extractors/APContactDataExtractor.m +++ b/Pod/Core/Private/Extractors/APContactDataExtractor.m @@ -17,6 +17,7 @@ #import "APSource.h" #import "APRelatedPerson.h" #import "APRecordDate.h" +#import "APDate.h" @implementation APContactDataExtractor @@ -155,6 +156,23 @@ - (NSArray *)linkedRecordIDs return linkedRecordIDs.array; } +- (NSArray *) dates +{ + return [self mapMultiValueOfProperty:kABPersonDateProperty + withBlock:^id(ABMultiValueRef multiValue, CFTypeRef value, CFIndex index) + { + APDate *date; + if (value) + { + date = [[APDate alloc] init]; + date.date = (__bridge NSDate *)ABMultiValueCopyValueAtIndex(multiValue, index); + date.originalLabel = [self originalLabelFromMultiValue:multiValue index:index]; + date.localizedLabel = [self localizedLabelFromMultiValue:multiValue index:index]; + } + return date; + }]; +} + - (APSource *)source { APSource *source; diff --git a/Pod/Core/Public/Models/APContact.h b/Pod/Core/Public/Models/APContact.h index 607d85e..e76253e 100755 --- a/Pod/Core/Public/Models/APContact.h +++ b/Pod/Core/Public/Models/APContact.h @@ -17,6 +17,7 @@ #import "APRelatedPerson.h" #import "APSource.h" #import "APRecordDate.h" +#import "APDate.h" @interface APContact : NSObject @@ -29,6 +30,7 @@ @property (nullable, nonatomic, strong) NSArray *addresses; @property (nullable, nonatomic, strong) NSArray *socialProfiles; @property (nullable, nonatomic, strong) NSDate *birthday; +@property (nullable, nonatomic, strong) NSArray *dates; @property (nullable, nonatomic, strong) NSString *note; @property (nullable, nonatomic, strong) NSArray *websites; @property (nullable, nonatomic, strong) NSArray *relatedPersons; diff --git a/Pod/Core/Public/Models/APDate.h b/Pod/Core/Public/Models/APDate.h new file mode 100644 index 0000000..08190b1 --- /dev/null +++ b/Pod/Core/Public/Models/APDate.h @@ -0,0 +1,17 @@ +// +// APDate.h +// Pods +// +// Created by Alexandre Plisson on 14/01/2016. +// +// + +#import + +@interface APDate : NSObject + +@property (nullable, nonatomic, strong) NSDate *date; +@property (nullable, nonatomic, strong) NSString *originalLabel; +@property (nullable, nonatomic, strong) NSString *localizedLabel; + +@end diff --git a/Pod/Core/Public/Models/APDate.m b/Pod/Core/Public/Models/APDate.m new file mode 100644 index 0000000..f391978 --- /dev/null +++ b/Pod/Core/Public/Models/APDate.m @@ -0,0 +1,13 @@ +// +// APDate.m +// Pods +// +// Created by Alexandre Plisson on 14/01/2016. +// +// + +#import "APDate.h" + +@implementation APDate + +@end diff --git a/Pod/Core/Public/Models/APTypes.h b/Pod/Core/Public/Models/APTypes.h index 97ee860..764dcca 100644 --- a/Pod/Core/Public/Models/APTypes.h +++ b/Pod/Core/Public/Models/APTypes.h @@ -29,6 +29,7 @@ typedef NS_OPTIONS(NSUInteger, APContactField) APContactFieldAddresses AP_DEPRECATED('APContactFieldAddressesOnly') = APContactFieldAddressesOnly, APContactFieldSocialProfiles = 1 << 9, APContactFieldBirthday = 1 << 10, + APContactFieldDates = 1 << 17, APContactFieldWebsites = 1 << 11, APContactFieldNote = 1 << 12, APContactFieldRelatedPersons = 1 << 13, diff --git a/Pod/Swift/APAddressBook-Bridging.h b/Pod/Swift/APAddressBook-Bridging.h index acff64b..ab6c176 100644 --- a/Pod/Swift/APAddressBook-Bridging.h +++ b/Pod/Swift/APAddressBook-Bridging.h @@ -20,3 +20,4 @@ #import "APRelatedPerson.h" #import "APSource.h" #import "APRecordDate.h" +#import "APDate.h"