diff --git a/JBDeviceOwner/JBDeviceOwner.h b/JBDeviceOwner/JBDeviceOwner.h index 81daf7c..3574d7c 100644 --- a/JBDeviceOwner/JBDeviceOwner.h +++ b/JBDeviceOwner/JBDeviceOwner.h @@ -20,5 +20,6 @@ @property (strong, nonatomic, readonly) NSString *lastName; @property (strong, nonatomic, readonly) NSString *middleName; @property (strong, nonatomic, readonly) NSString *phone; +@property (strong, nonatomic, readonly) UIImage *photo; @end diff --git a/JBDeviceOwner/JBDeviceOwner.m b/JBDeviceOwner/JBDeviceOwner.m index 774f931..9bf8e49 100644 --- a/JBDeviceOwner/JBDeviceOwner.m +++ b/JBDeviceOwner/JBDeviceOwner.m @@ -19,6 +19,7 @@ @interface JBDeviceOwner () @property (strong, nonatomic, readwrite) NSString *lastName; @property (strong, nonatomic, readwrite) NSString *middleName; @property (strong, nonatomic, readwrite) NSString *phone; +@property (strong, nonatomic, readwrite) UIImage *photo; - (void)populateFromAddressBook; @@ -34,6 +35,8 @@ @implementation JBDeviceOwner @synthesize lastName; @synthesize middleName; @synthesize phone; +@synthesize photo; + #pragma mark - Creation/Removal Methods @@ -45,9 +48,11 @@ - (id)initWithDevice:(UIDevice *)aDevice { NSMutableString *deviceName = [NSMutableString stringWithString:self.device.name]; NSArray *stringsToStrip = [NSArray arrayWithObjects:@"'s", + @"’s", @"ipad", - @"iphone" - @"ipod touch", nil]; + @"iphone", + @"ipod touch", + @"ipod", nil]; for (NSString *stringToStrip in stringsToStrip) { [deviceName replaceOccurrencesOfString:stringToStrip @@ -104,6 +109,19 @@ - (void)populateFromAddressBook { } CFRelease(phoneMultiValue); + + // Photo + if( ABPersonHasImageData( owner )) { + + if( &ABPersonCopyImageDataWithFormat != nil ) { + + CFDataRef data = ABPersonCopyImageDataWithFormat( owner, kABPersonImageFormatThumbnail ); + + self.photo = [UIImage imageWithData:(__bridge NSData *)data]; + + CFRelease( data ); + } + } } CFRelease(addressBook);