Skip to content

Commit

Permalink
Merge pull request #2 from carlosefonseca/master
Browse files Browse the repository at this point in the history
Added optional fetch of thumbnail photo
  • Loading branch information
belkevich committed Jan 20, 2014
2 parents 7abd242 + 973315e commit 937bec5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions Classes/APContact.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
@property (nonatomic, readonly) NSArray *phones;
@property (nonatomic, readonly) NSArray *emails;
@property (nonatomic, readonly) UIImage *photo;
@property (nonatomic, readonly) UIImage *photoThumb;

- (id)initWithRecordRef:(ABRecordRef)recordRef fieldMask:(APContactField)fieldMask;

Expand Down
5 changes: 5 additions & 0 deletions Classes/APContact.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ - (id)initWithRecordRef:(ABRecordRef)recordRef fieldMask:(APContactField)fieldMa
NSData *imageData = (__bridge_transfer NSData *)ABPersonCopyImageData(recordRef);
_photo = [UIImage imageWithData:imageData scale:UIScreen.mainScreen.scale];
}
if (fieldMask & APContactFieldPhotoThumb)
{
NSData *imageData = (__bridge_transfer NSData *)ABPersonCopyImageDataWithFormat(recordRef, kABPersonImageFormatThumbnail);
_photoThumb = [UIImage imageWithData:imageData scale:UIScreen.mainScreen.scale];
}
}
return self;
}
Expand Down
3 changes: 2 additions & 1 deletion Classes/APTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ typedef enum
APContactFieldPhones = 1 << 3,
APContactFieldEmails = 1 << 4,
APContactFieldPhoto = 1 << 5,
APContactFieldPhotoThumb= 1 << 6,
APContactFieldDefault = APContactFieldFirstName | APContactFieldLastName |
APContactFieldPhones,
APContactFieldAll = APContactFieldDefault | APContactFieldCompany |
APContactFieldEmails | APContactFieldPhoto
APContactFieldEmails | APContactFieldPhoto | APContactFieldPhotoThumb
} APContactField;

#endif

0 comments on commit 937bec5

Please sign in to comment.