Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added support for pulling the owners profile photo from the addressbook. #4

Open
wants to merge 2 commits into from

4 participants

@touchbee

No description provided.

@jakeboxer
Owner

Hey @touchbee,

This looks pretty good. A few quick changes that would be great before I merge this:

  1. Remove the logic for < iOS 4.1. This framework requires iOS 5+ to run anyways.
  2. Change the check for "ipod touch" to just "touch". The way it is now, if the device name is "First Last's iPod Touch", I believe it'll be changed to "First Last Touch".
  3. Try to stay consistent with my coding style. Your indentation and spacing looks a bit different than mine (which is fine normally, but I'd like to keep it consistent within this project).
@touchbee

Hi Jake,

  1. I'll check that out.
  2. Yeah I think I'm using the default indentation. Wondered why it looks like that. What indentation are you using? 2 spaces?
touchbee Pulled "iPod touch" before "iPod".
Removed image retrieval for iOS < 4.2.
Reformatted code.
42a94b3
@jakeboxer
Owner

@touchbee yep, 2 spaces. Also, keep an eye on other little things. For example, I don't do spaces inside parentheses or a blank line after every line of code.

@horak

Hi @touchbee @jakeboxer, I'd love to see this PR get merged in for a project I'm working on! Could you take another look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 12, 2012
Commits on Apr 14, 2012
  1. Pulled "iPod touch" before "iPod".

    touchbee authored
    Removed image retrieval for iOS < 4.2.
    Reformatted code.
This page is out of date. Refresh to see the latest.
Showing with 21 additions and 2 deletions.
  1. +1 −0  JBDeviceOwner/JBDeviceOwner.h
  2. +20 −2 JBDeviceOwner/JBDeviceOwner.m
View
1  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
View
22 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);
Something went wrong with that request. Please try again.