Skip to content

Commit

Permalink
Merge pull request #116 from alexpli/master
Browse files Browse the repository at this point in the history
Other dates support
  • Loading branch information
belkevich committed Jan 14, 2016
2 parents ceb2f1f + 3ec9afa commit e886d57
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Pod/Core/Private/Builders/APContactBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
1 change: 1 addition & 0 deletions Pod/Core/Private/Extractors/APContactDataExtractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- (NSArray *)socialProfiles;
- (NSArray *)relatedPersons;
- (NSArray *)linkedRecordIDs;
- (NSArray *)dates;
- (APSource *)source;
- (APRecordDate *)recordDate;
- (NSString *)stringProperty:(ABPropertyID)property;
Expand Down
18 changes: 18 additions & 0 deletions Pod/Core/Private/Extractors/APContactDataExtractor.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#import "APSource.h"
#import "APRelatedPerson.h"
#import "APRecordDate.h"
#import "APDate.h"

@implementation APContactDataExtractor

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions Pod/Core/Public/Models/APContact.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#import "APRelatedPerson.h"
#import "APSource.h"
#import "APRecordDate.h"
#import "APDate.h"

@interface APContact : NSObject

Expand All @@ -29,6 +30,7 @@
@property (nullable, nonatomic, strong) NSArray <APAddress *> *addresses;
@property (nullable, nonatomic, strong) NSArray <APSocialProfile *> *socialProfiles;
@property (nullable, nonatomic, strong) NSDate *birthday;
@property (nullable, nonatomic, strong) NSArray <APDate *> *dates;
@property (nullable, nonatomic, strong) NSString *note;
@property (nullable, nonatomic, strong) NSArray <NSString *> *websites;
@property (nullable, nonatomic, strong) NSArray <APRelatedPerson *> *relatedPersons;
Expand Down
17 changes: 17 additions & 0 deletions Pod/Core/Public/Models/APDate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// APDate.h
// Pods
//
// Created by Alexandre Plisson on 14/01/2016.
//
//

#import <Foundation/Foundation.h>

@interface APDate : NSObject

@property (nullable, nonatomic, strong) NSDate *date;
@property (nullable, nonatomic, strong) NSString *originalLabel;
@property (nullable, nonatomic, strong) NSString *localizedLabel;

@end
13 changes: 13 additions & 0 deletions Pod/Core/Public/Models/APDate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// APDate.m
// Pods
//
// Created by Alexandre Plisson on 14/01/2016.
//
//

#import "APDate.h"

@implementation APDate

@end
1 change: 1 addition & 0 deletions Pod/Core/Public/Models/APTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions Pod/Swift/APAddressBook-Bridging.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
#import "APRelatedPerson.h"
#import "APSource.h"
#import "APRecordDate.h"
#import "APDate.h"

0 comments on commit e886d57

Please sign in to comment.