├── .gitignore ├── .travis.yml ├── AFAddressBookManager.podspec ├── AFAddressBookManager.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── AFAddressBookManager.xcscheme ├── AFAddressBookManager ├── AFAddressBookManager.h ├── AFAddressBookManager.m ├── AFContact.h ├── AFContact.m ├── NSString+UnformattedPhoneNumber.h └── NSString+UnformattedPhoneNumber.m ├── Demo ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ └── Main.storyboard ├── Default-568h@2x.png ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | !default.xcworkspace 13 | xcuserdata 14 | profile 15 | *.moved-aside 16 | DerivedData 17 | .idea/ 18 | *.xccheckout 19 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | 3 | script: 4 | - pod lib lint 5 | - xctool -project AFAddressBookManager.xcodeproj -scheme 'AFAddressBookManager' -sdk iphonesimulator build 6 | -------------------------------------------------------------------------------- /AFAddressBookManager.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'AFAddressBookManager' 3 | s.version = '1.2.1' 4 | s.summary = 'Get contacts from AddressBook by their phone numbers.' 5 | s.homepage = 'https://github.com/Fogh/AFAddressBookManager' 6 | s.license = 'MIT' 7 | s.author = { 'Anders Fogh Eriksen' => 'andfogh@gmail.com' } 8 | s.source = { :git => 'https://github.com/Fogh/AFAddressBookManager.git', :tag => s.version.to_s } 9 | s.platform = :ios, '6.0' 10 | s.source_files = 'AFAddressBookManager/*.{h,m}' 11 | s.framework = 'AddressBook' 12 | s.requires_arc = true 13 | s.social_media_url = 'https://twitter.com/f0gh' 14 | s.deprecated = true 15 | end 16 | -------------------------------------------------------------------------------- /AFAddressBookManager.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 5F25B9431A93C04F007ABD13 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F25B9381A93C04F007ABD13 /* AppDelegate.m */; }; 11 | 5F25B9461A93C04F007ABD13 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5F25B93E1A93C04F007ABD13 /* Images.xcassets */; }; 12 | 5F25B9481A93C04F007ABD13 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F25B9401A93C04F007ABD13 /* main.m */; }; 13 | 5F25B9491A93C04F007ABD13 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F25B9421A93C04F007ABD13 /* ViewController.m */; }; 14 | 5F25B9571A93C0AE007ABD13 /* AFAddressBookManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F25B9521A93C0AE007ABD13 /* AFAddressBookManager.m */; }; 15 | 5F25B9581A93C0AE007ABD13 /* AFContact.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F25B9541A93C0AE007ABD13 /* AFContact.m */; }; 16 | 5F25B9591A93C0AE007ABD13 /* NSString+UnformattedPhoneNumber.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F25B9561A93C0AE007ABD13 /* NSString+UnformattedPhoneNumber.m */; }; 17 | 5F25B95C1A93C188007ABD13 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5F25B94C1A93C088007ABD13 /* Main.storyboard */; }; 18 | 5F745D161A93C3CF00165C72 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 5F745D151A93C3CF00165C72 /* Default-568h@2x.png */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXFileReference section */ 22 | 5F25B9041A93BCE1007ABD13 /* AFAddressBookManager.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AFAddressBookManager.app; sourceTree = BUILT_PRODUCTS_DIR; }; 23 | 5F25B9371A93C04F007ABD13 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = Demo/AppDelegate.h; sourceTree = SOURCE_ROOT; }; 24 | 5F25B9381A93C04F007ABD13 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = Demo/AppDelegate.m; sourceTree = SOURCE_ROOT; }; 25 | 5F25B93E1A93C04F007ABD13 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = Demo/Images.xcassets; sourceTree = SOURCE_ROOT; }; 26 | 5F25B93F1A93C04F007ABD13 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Demo/Info.plist; sourceTree = SOURCE_ROOT; }; 27 | 5F25B9401A93C04F007ABD13 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = Demo/main.m; sourceTree = SOURCE_ROOT; }; 28 | 5F25B9411A93C04F007ABD13 /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ViewController.h; path = Demo/ViewController.h; sourceTree = SOURCE_ROOT; }; 29 | 5F25B9421A93C04F007ABD13 /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ViewController.m; path = Demo/ViewController.m; sourceTree = SOURCE_ROOT; }; 30 | 5F25B94D1A93C088007ABD13 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Demo/Base.lproj/Main.storyboard; sourceTree = SOURCE_ROOT; }; 31 | 5F25B9511A93C0AE007ABD13 /* AFAddressBookManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFAddressBookManager.h; sourceTree = ""; }; 32 | 5F25B9521A93C0AE007ABD13 /* AFAddressBookManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFAddressBookManager.m; sourceTree = ""; }; 33 | 5F25B9531A93C0AE007ABD13 /* AFContact.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFContact.h; sourceTree = ""; }; 34 | 5F25B9541A93C0AE007ABD13 /* AFContact.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFContact.m; sourceTree = ""; }; 35 | 5F25B9551A93C0AE007ABD13 /* NSString+UnformattedPhoneNumber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+UnformattedPhoneNumber.h"; sourceTree = ""; }; 36 | 5F25B9561A93C0AE007ABD13 /* NSString+UnformattedPhoneNumber.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+UnformattedPhoneNumber.m"; sourceTree = ""; }; 37 | 5F745D151A93C3CF00165C72 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "Demo/Default-568h@2x.png"; sourceTree = SOURCE_ROOT; }; 38 | /* End PBXFileReference section */ 39 | 40 | /* Begin PBXFrameworksBuildPhase section */ 41 | 5F25B9011A93BCE1007ABD13 /* Frameworks */ = { 42 | isa = PBXFrameworksBuildPhase; 43 | buildActionMask = 2147483647; 44 | files = ( 45 | ); 46 | runOnlyForDeploymentPostprocessing = 0; 47 | }; 48 | /* End PBXFrameworksBuildPhase section */ 49 | 50 | /* Begin PBXGroup section */ 51 | 5F25B8FB1A93BCE1007ABD13 = { 52 | isa = PBXGroup; 53 | children = ( 54 | 5F25B9061A93BCE1007ABD13 /* AFAddressBookManager */, 55 | 5F25B9051A93BCE1007ABD13 /* Products */, 56 | ); 57 | sourceTree = ""; 58 | }; 59 | 5F25B9051A93BCE1007ABD13 /* Products */ = { 60 | isa = PBXGroup; 61 | children = ( 62 | 5F25B9041A93BCE1007ABD13 /* AFAddressBookManager.app */, 63 | ); 64 | name = Products; 65 | sourceTree = ""; 66 | }; 67 | 5F25B9061A93BCE1007ABD13 /* AFAddressBookManager */ = { 68 | isa = PBXGroup; 69 | children = ( 70 | 5F25B9501A93C0AE007ABD13 /* AFAddressBookManager */, 71 | 5F25B9371A93C04F007ABD13 /* AppDelegate.h */, 72 | 5F25B9381A93C04F007ABD13 /* AppDelegate.m */, 73 | 5F25B9411A93C04F007ABD13 /* ViewController.h */, 74 | 5F25B9421A93C04F007ABD13 /* ViewController.m */, 75 | 5F25B9071A93BCE1007ABD13 /* Supporting Files */, 76 | ); 77 | path = AFAddressBookManager; 78 | sourceTree = ""; 79 | }; 80 | 5F25B9071A93BCE1007ABD13 /* Supporting Files */ = { 81 | isa = PBXGroup; 82 | children = ( 83 | 5F745D151A93C3CF00165C72 /* Default-568h@2x.png */, 84 | 5F25B93E1A93C04F007ABD13 /* Images.xcassets */, 85 | 5F25B94C1A93C088007ABD13 /* Main.storyboard */, 86 | 5F25B93F1A93C04F007ABD13 /* Info.plist */, 87 | 5F25B9401A93C04F007ABD13 /* main.m */, 88 | ); 89 | name = "Supporting Files"; 90 | sourceTree = ""; 91 | }; 92 | 5F25B9501A93C0AE007ABD13 /* AFAddressBookManager */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | 5F25B9511A93C0AE007ABD13 /* AFAddressBookManager.h */, 96 | 5F25B9521A93C0AE007ABD13 /* AFAddressBookManager.m */, 97 | 5F25B9531A93C0AE007ABD13 /* AFContact.h */, 98 | 5F25B9541A93C0AE007ABD13 /* AFContact.m */, 99 | 5F25B9551A93C0AE007ABD13 /* NSString+UnformattedPhoneNumber.h */, 100 | 5F25B9561A93C0AE007ABD13 /* NSString+UnformattedPhoneNumber.m */, 101 | ); 102 | name = AFAddressBookManager; 103 | sourceTree = ""; 104 | }; 105 | /* End PBXGroup section */ 106 | 107 | /* Begin PBXNativeTarget section */ 108 | 5F25B9031A93BCE1007ABD13 /* AFAddressBookManager */ = { 109 | isa = PBXNativeTarget; 110 | buildConfigurationList = 5F25B9271A93BCE1007ABD13 /* Build configuration list for PBXNativeTarget "AFAddressBookManager" */; 111 | buildPhases = ( 112 | 5F25B9001A93BCE1007ABD13 /* Sources */, 113 | 5F25B9011A93BCE1007ABD13 /* Frameworks */, 114 | 5F25B9021A93BCE1007ABD13 /* Resources */, 115 | ); 116 | buildRules = ( 117 | ); 118 | dependencies = ( 119 | ); 120 | name = AFAddressBookManager; 121 | productName = AFAddressBookManager; 122 | productReference = 5F25B9041A93BCE1007ABD13 /* AFAddressBookManager.app */; 123 | productType = "com.apple.product-type.application"; 124 | }; 125 | /* End PBXNativeTarget section */ 126 | 127 | /* Begin PBXProject section */ 128 | 5F25B8FC1A93BCE1007ABD13 /* Project object */ = { 129 | isa = PBXProject; 130 | attributes = { 131 | LastUpgradeCheck = 0610; 132 | ORGANIZATIONNAME = "Anders Fogh Eriksen"; 133 | TargetAttributes = { 134 | 5F25B9031A93BCE1007ABD13 = { 135 | CreatedOnToolsVersion = 6.1.1; 136 | }; 137 | }; 138 | }; 139 | buildConfigurationList = 5F25B8FF1A93BCE1007ABD13 /* Build configuration list for PBXProject "AFAddressBookManager" */; 140 | compatibilityVersion = "Xcode 3.2"; 141 | developmentRegion = English; 142 | hasScannedForEncodings = 0; 143 | knownRegions = ( 144 | en, 145 | Base, 146 | ); 147 | mainGroup = 5F25B8FB1A93BCE1007ABD13; 148 | productRefGroup = 5F25B9051A93BCE1007ABD13 /* Products */; 149 | projectDirPath = ""; 150 | projectRoot = ""; 151 | targets = ( 152 | 5F25B9031A93BCE1007ABD13 /* AFAddressBookManager */, 153 | ); 154 | }; 155 | /* End PBXProject section */ 156 | 157 | /* Begin PBXResourcesBuildPhase section */ 158 | 5F25B9021A93BCE1007ABD13 /* Resources */ = { 159 | isa = PBXResourcesBuildPhase; 160 | buildActionMask = 2147483647; 161 | files = ( 162 | 5F25B95C1A93C188007ABD13 /* Main.storyboard in Resources */, 163 | 5F25B9461A93C04F007ABD13 /* Images.xcassets in Resources */, 164 | 5F745D161A93C3CF00165C72 /* Default-568h@2x.png in Resources */, 165 | ); 166 | runOnlyForDeploymentPostprocessing = 0; 167 | }; 168 | /* End PBXResourcesBuildPhase section */ 169 | 170 | /* Begin PBXSourcesBuildPhase section */ 171 | 5F25B9001A93BCE1007ABD13 /* Sources */ = { 172 | isa = PBXSourcesBuildPhase; 173 | buildActionMask = 2147483647; 174 | files = ( 175 | 5F25B9571A93C0AE007ABD13 /* AFAddressBookManager.m in Sources */, 176 | 5F25B9591A93C0AE007ABD13 /* NSString+UnformattedPhoneNumber.m in Sources */, 177 | 5F25B9491A93C04F007ABD13 /* ViewController.m in Sources */, 178 | 5F25B9581A93C0AE007ABD13 /* AFContact.m in Sources */, 179 | 5F25B9481A93C04F007ABD13 /* main.m in Sources */, 180 | 5F25B9431A93C04F007ABD13 /* AppDelegate.m in Sources */, 181 | ); 182 | runOnlyForDeploymentPostprocessing = 0; 183 | }; 184 | /* End PBXSourcesBuildPhase section */ 185 | 186 | /* Begin PBXVariantGroup section */ 187 | 5F25B94C1A93C088007ABD13 /* Main.storyboard */ = { 188 | isa = PBXVariantGroup; 189 | children = ( 190 | 5F25B94D1A93C088007ABD13 /* Base */, 191 | ); 192 | name = Main.storyboard; 193 | sourceTree = ""; 194 | }; 195 | /* End PBXVariantGroup section */ 196 | 197 | /* Begin XCBuildConfiguration section */ 198 | 5F25B9251A93BCE1007ABD13 /* Debug */ = { 199 | isa = XCBuildConfiguration; 200 | buildSettings = { 201 | ALWAYS_SEARCH_USER_PATHS = NO; 202 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 203 | CLANG_CXX_LIBRARY = "libc++"; 204 | CLANG_ENABLE_MODULES = YES; 205 | CLANG_ENABLE_OBJC_ARC = YES; 206 | CLANG_WARN_BOOL_CONVERSION = YES; 207 | CLANG_WARN_CONSTANT_CONVERSION = YES; 208 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 209 | CLANG_WARN_EMPTY_BODY = YES; 210 | CLANG_WARN_ENUM_CONVERSION = YES; 211 | CLANG_WARN_INT_CONVERSION = YES; 212 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 213 | CLANG_WARN_UNREACHABLE_CODE = YES; 214 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 215 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 216 | COPY_PHASE_STRIP = NO; 217 | ENABLE_STRICT_OBJC_MSGSEND = YES; 218 | GCC_C_LANGUAGE_STANDARD = gnu99; 219 | GCC_DYNAMIC_NO_PIC = NO; 220 | GCC_OPTIMIZATION_LEVEL = 0; 221 | GCC_PREPROCESSOR_DEFINITIONS = ( 222 | "DEBUG=1", 223 | "$(inherited)", 224 | ); 225 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 226 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 227 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 228 | GCC_WARN_UNDECLARED_SELECTOR = YES; 229 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 230 | GCC_WARN_UNUSED_FUNCTION = YES; 231 | GCC_WARN_UNUSED_VARIABLE = YES; 232 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 233 | MTL_ENABLE_DEBUG_INFO = YES; 234 | ONLY_ACTIVE_ARCH = YES; 235 | SDKROOT = iphoneos; 236 | TARGETED_DEVICE_FAMILY = "1,2"; 237 | }; 238 | name = Debug; 239 | }; 240 | 5F25B9261A93BCE1007ABD13 /* Release */ = { 241 | isa = XCBuildConfiguration; 242 | buildSettings = { 243 | ALWAYS_SEARCH_USER_PATHS = NO; 244 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 245 | CLANG_CXX_LIBRARY = "libc++"; 246 | CLANG_ENABLE_MODULES = YES; 247 | CLANG_ENABLE_OBJC_ARC = YES; 248 | CLANG_WARN_BOOL_CONVERSION = YES; 249 | CLANG_WARN_CONSTANT_CONVERSION = YES; 250 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 251 | CLANG_WARN_EMPTY_BODY = YES; 252 | CLANG_WARN_ENUM_CONVERSION = YES; 253 | CLANG_WARN_INT_CONVERSION = YES; 254 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 255 | CLANG_WARN_UNREACHABLE_CODE = YES; 256 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 257 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 258 | COPY_PHASE_STRIP = YES; 259 | ENABLE_NS_ASSERTIONS = NO; 260 | ENABLE_STRICT_OBJC_MSGSEND = YES; 261 | GCC_C_LANGUAGE_STANDARD = gnu99; 262 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 263 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 264 | GCC_WARN_UNDECLARED_SELECTOR = YES; 265 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 266 | GCC_WARN_UNUSED_FUNCTION = YES; 267 | GCC_WARN_UNUSED_VARIABLE = YES; 268 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 269 | MTL_ENABLE_DEBUG_INFO = NO; 270 | SDKROOT = iphoneos; 271 | TARGETED_DEVICE_FAMILY = "1,2"; 272 | VALIDATE_PRODUCT = YES; 273 | }; 274 | name = Release; 275 | }; 276 | 5F25B9281A93BCE1007ABD13 /* Debug */ = { 277 | isa = XCBuildConfiguration; 278 | buildSettings = { 279 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 280 | INFOPLIST_FILE = "$(SRCROOT)/Demo/Info.plist"; 281 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 282 | PRODUCT_NAME = "$(TARGET_NAME)"; 283 | }; 284 | name = Debug; 285 | }; 286 | 5F25B9291A93BCE1007ABD13 /* Release */ = { 287 | isa = XCBuildConfiguration; 288 | buildSettings = { 289 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 290 | INFOPLIST_FILE = "$(SRCROOT)/Demo/Info.plist"; 291 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 292 | PRODUCT_NAME = "$(TARGET_NAME)"; 293 | }; 294 | name = Release; 295 | }; 296 | /* End XCBuildConfiguration section */ 297 | 298 | /* Begin XCConfigurationList section */ 299 | 5F25B8FF1A93BCE1007ABD13 /* Build configuration list for PBXProject "AFAddressBookManager" */ = { 300 | isa = XCConfigurationList; 301 | buildConfigurations = ( 302 | 5F25B9251A93BCE1007ABD13 /* Debug */, 303 | 5F25B9261A93BCE1007ABD13 /* Release */, 304 | ); 305 | defaultConfigurationIsVisible = 0; 306 | defaultConfigurationName = Release; 307 | }; 308 | 5F25B9271A93BCE1007ABD13 /* Build configuration list for PBXNativeTarget "AFAddressBookManager" */ = { 309 | isa = XCConfigurationList; 310 | buildConfigurations = ( 311 | 5F25B9281A93BCE1007ABD13 /* Debug */, 312 | 5F25B9291A93BCE1007ABD13 /* Release */, 313 | ); 314 | defaultConfigurationIsVisible = 0; 315 | defaultConfigurationName = Release; 316 | }; 317 | /* End XCConfigurationList section */ 318 | }; 319 | rootObject = 5F25B8FC1A93BCE1007ABD13 /* Project object */; 320 | } 321 | -------------------------------------------------------------------------------- /AFAddressBookManager.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /AFAddressBookManager.xcodeproj/xcshareddata/xcschemes/AFAddressBookManager.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 94 | 100 | 101 | 102 | 103 | 105 | 106 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /AFAddressBookManager/AFAddressBookManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // AFAddressBookManager.h 3 | // 4 | // Created by Anders Fogh Eriksen on 09/04/13. 5 | // Copyright (c) 2013-2015 Anders Eriksen. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @interface AFAddressBookManager : NSObject 12 | 13 | /** 14 | * Get name of contact with specific phone number. 15 | * 16 | * @param phoneNumber Phone number for the contact. 17 | * 18 | * @return Name of contact. 19 | */ 20 | + (NSString *)nameForContactWithPhoneNumber:(NSString *)phoneNumber; 21 | 22 | /** 23 | * Get photo of contact with specific phone number. 24 | * 25 | * @param phoneNumber Phone number for the contact. 26 | * 27 | * @return Photo of contact. 28 | */ 29 | + (UIImage *)photoForContactWithPhoneNumber:(NSString *)phoneNumber; 30 | 31 | /** 32 | * Get name of contact with specific email address. 33 | * 34 | * @param emailAddress Email address for the contact. 35 | * 36 | * @return Name of contact. 37 | */ 38 | + (NSString *)nameForContactWithEmailAddress:(NSString *)emailAddress; 39 | 40 | /** 41 | * Get photo of contact with specific email address. 42 | * 43 | * @param emailAddress Email address for the contact. 44 | * 45 | * @return Photo of contact. 46 | */ 47 | + (UIImage *)photoForContactWithEmailAddress:(NSString *)emailAddress; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /AFAddressBookManager/AFAddressBookManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // AFAddressBookManager.m 3 | // 4 | // Created by Anders Fogh Eriksen on 09/04/13. 5 | // Copyright (c) 2013-2015 Anders Eriksen. All rights reserved. 6 | // 7 | 8 | #import "AFAddressBookManager.h" 9 | #import 10 | #import "AFContact.h" 11 | #import "NSString+UnformattedPhoneNumber.h" 12 | 13 | @implementation AFAddressBookManager 14 | 15 | + (NSArray *)allContactsFromAddressBook 16 | { 17 | static NSMutableArray *contacts = nil; 18 | static dispatch_once_t onceToken; 19 | 20 | dispatch_once(&onceToken, ^{ 21 | CFErrorRef *error = nil; 22 | ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, error); 23 | 24 | __block BOOL accessGranted = NO; 25 | 26 | // Semaphore is used for blocking until response 27 | dispatch_semaphore_t sema = dispatch_semaphore_create(0); 28 | 29 | ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) { 30 | accessGranted = granted; 31 | dispatch_semaphore_signal(sema); 32 | }); 33 | 34 | dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER); 35 | 36 | if (accessGranted) { 37 | NSArray *allPeople = (__bridge_transfer NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook); 38 | contacts = [NSMutableArray arrayWithCapacity:allPeople.count]; 39 | 40 | for (id person in allPeople) { 41 | @autoreleasepool { 42 | AFContact *contact = [AFContact new]; 43 | 44 | // Get the name of the contact 45 | NSString *firstName = (__bridge_transfer NSString*)ABRecordCopyValue((__bridge ABRecordRef)(person), kABPersonFirstNameProperty) ?: @""; 46 | NSString *lastName = (__bridge_transfer NSString*)ABRecordCopyValue((__bridge ABRecordRef)(person), kABPersonLastNameProperty) ?: @""; 47 | 48 | contact.name = [NSString stringWithFormat:@"%@ %@", firstName, lastName]; 49 | 50 | // Get the photo of the contact 51 | CFDataRef imageData = ABPersonCopyImageData((__bridge ABRecordRef)(person)); 52 | UIImage *image = [UIImage imageWithData:(__bridge NSData *)imageData]; 53 | if (imageData) { 54 | CFRelease(imageData); 55 | } 56 | contact.photo = image; 57 | 58 | // Get all phone numbers of the contact 59 | ABMultiValueRef phoneNumbers = ABRecordCopyValue((__bridge ABRecordRef)(person), kABPersonPhoneProperty); 60 | 61 | // If the contact has multiple phone numbers, iterate on each of them 62 | NSInteger phoneNumberCount = ABMultiValueGetCount(phoneNumbers); 63 | NSMutableArray *tempArray = [NSMutableArray arrayWithCapacity:phoneNumberCount]; 64 | for (int i = 0; i < phoneNumberCount; i++) { 65 | NSString *phoneNumberFromAB = [(__bridge_transfer NSString*)ABMultiValueCopyValueAtIndex(phoneNumbers, i) unformattedPhoneNumber]; 66 | [tempArray addObject:phoneNumberFromAB]; 67 | } 68 | CFRelease(phoneNumbers); 69 | contact.numbers = tempArray; 70 | 71 | // Get all email addresses of the contact 72 | ABMultiValueRef emailAddresses = ABRecordCopyValue((__bridge ABRecordRef)(person), kABPersonEmailProperty); 73 | 74 | // If the contact has multiple email addresses, iterate on each of them 75 | NSInteger emailAddressCount = ABMultiValueGetCount(emailAddresses); 76 | NSMutableArray *emailArray = [NSMutableArray arrayWithCapacity:emailAddressCount]; 77 | for (int i = 0; i < emailAddressCount; i++) { 78 | NSString *emailAddressFromAB = (__bridge_transfer NSString*)ABMultiValueCopyValueAtIndex(emailAddresses, i); 79 | [emailArray addObject:emailAddressFromAB]; 80 | } 81 | CFRelease(emailAddresses); 82 | contact.emails = emailArray; 83 | 84 | [contacts addObject:contact]; 85 | } 86 | } 87 | } 88 | CFRelease(addressBook); 89 | }); 90 | 91 | return contacts; 92 | } 93 | 94 | + (AFContact *)findContactWithPhoneNumber:(NSString *)phoneNumber 95 | { 96 | NSArray *contacts = [AFAddressBookManager allContactsFromAddressBook]; 97 | 98 | NSPredicate *predicate = [NSPredicate predicateWithFormat:@"numbers contains %@", phoneNumber]; 99 | NSArray *filteredArray = [contacts filteredArrayUsingPredicate:predicate]; 100 | 101 | AFContact *matchedContact = filteredArray.lastObject; 102 | return matchedContact; 103 | } 104 | 105 | + (AFContact *)findContactWithEmailAddress:(NSString *)emailAddress 106 | { 107 | NSArray *contacts = [AFAddressBookManager allContactsFromAddressBook]; 108 | 109 | NSPredicate *predicate = [NSPredicate predicateWithFormat:@"emails contains %@", emailAddress]; 110 | NSArray *filteredArray = [contacts filteredArrayUsingPredicate:predicate]; 111 | 112 | AFContact *matchedContact = filteredArray.lastObject; 113 | return matchedContact; 114 | } 115 | 116 | + (NSString *)nameForContactWithPhoneNumber:(NSString *)phoneNumber 117 | { 118 | return [AFAddressBookManager findContactWithPhoneNumber:phoneNumber].name; 119 | } 120 | 121 | + (UIImage *)photoForContactWithPhoneNumber:(NSString *)phoneNumber 122 | { 123 | return [AFAddressBookManager findContactWithPhoneNumber:phoneNumber].photo; 124 | } 125 | 126 | + (NSString *)nameForContactWithEmailAddress:(NSString *)emailAddress 127 | { 128 | return [AFAddressBookManager findContactWithEmailAddress:emailAddress].name; 129 | } 130 | 131 | + (UIImage *)photoForContactWithEmailAddress:(NSString *)emailAddress 132 | { 133 | return [AFAddressBookManager findContactWithEmailAddress:emailAddress].photo; 134 | } 135 | 136 | @end 137 | -------------------------------------------------------------------------------- /AFAddressBookManager/AFContact.h: -------------------------------------------------------------------------------- 1 | // 2 | // AFContact.h 3 | // 4 | // Created by Anders Fogh Eriksen on 09/04/13. 5 | // Copyright (c) 2013-2015 Anders Eriksen. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @interface AFContact : NSObject 12 | 13 | @property (nonatomic, strong) NSString *name; 14 | @property (nonatomic, strong) NSArray *numbers; 15 | @property (nonatomic, strong) NSArray *emails; 16 | @property (nonatomic, strong) UIImage *photo; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /AFAddressBookManager/AFContact.m: -------------------------------------------------------------------------------- 1 | // 2 | // AFContact.m 3 | // 4 | // Created by Anders Fogh Eriksen on 09/04/13. 5 | // Copyright (c) 2013-2015 Anders Eriksen. All rights reserved. 6 | // 7 | 8 | #import "AFContact.h" 9 | 10 | @implementation AFContact 11 | @end 12 | -------------------------------------------------------------------------------- /AFAddressBookManager/NSString+UnformattedPhoneNumber.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+UnformattedPhoneNumber.h 3 | // 4 | // Created by Anders Fogh Eriksen on 09/04/13. 5 | // Copyright (c) 2013-2015 Anders Eriksen. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @interface NSString (UnformattedPhoneNumber) 11 | 12 | - (NSString *)unformattedPhoneNumber; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /AFAddressBookManager/NSString+UnformattedPhoneNumber.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+UnformattedPhoneNumber.m 3 | // 4 | // Created by Anders Fogh Eriksen on 09/04/13. 5 | // Copyright (c) 2013-2015 Anders Eriksen. All rights reserved. 6 | // 7 | 8 | #import "NSString+UnformattedPhoneNumber.h" 9 | 10 | @implementation NSString (UnformattedPhoneNumber) 11 | 12 | - (NSString *)unformattedPhoneNumber 13 | { 14 | NSCharacterSet *toExclude = [NSCharacterSet characterSetWithCharactersInString:@"/.,()-+ "]; 15 | return [[self componentsSeparatedByCharactersInSet:toExclude] componentsJoinedByString:@""]; 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Demo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // AFAddressBookManager 4 | // 5 | // Created by Anders Eriksen on 17/02/15. 6 | // Copyright (c) 2015 Anders Fogh Eriksen. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /Demo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // AFAddressBookManager 4 | // 5 | // Created by Anders Eriksen on 17/02/15. 6 | // Copyright (c) 2015 Anders Fogh Eriksen. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @implementation AppDelegate 12 | 13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 14 | { 15 | return YES; 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Demo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Demo/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fogh/AFAddressBookManager/5dacb19e50d7a0cacb09fafadeb3270a07f48aa1/Demo/Default-568h@2x.png -------------------------------------------------------------------------------- /Demo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /Demo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | dk.foghdev.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Demo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // AFAddressBookManager 4 | // 5 | // Created by Anders Eriksen on 17/02/15. 6 | // Copyright (c) 2015 Anders Fogh Eriksen. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /Demo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // AFAddressBookManager 4 | // 5 | // Created by Anders Eriksen on 17/02/15. 6 | // Copyright (c) 2015 Anders Fogh Eriksen. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @implementation ViewController 12 | 13 | - (void)viewDidLoad 14 | { 15 | [super viewDidLoad]; 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Demo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // AFAddressBookManager 4 | // 5 | // Created by Anders Eriksen on 17/02/15. 6 | // Copyright (c) 2015 Anders Fogh Eriksen. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2015 Anders Fogh Eriksen 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | AFAddressBookManager 2 | ==================== 3 | ![Pod version](http://img.shields.io/cocoapods/v/AFAddressBookManager.svg?style=flat) 4 | ![Pod platform](http://img.shields.io/cocoapods/p/AFAddressBookManager.svg?style=flat) 5 | [![Build Status](https://travis-ci.org/Fogh/AFAddressBookManager.svg?branch=master)](https://travis-ci.org/Fogh/AFAddressBookManager) 6 | 7 | Get contacts from iOS Address Book by their phone numbers and email addresses. Works on iOS 6+. 8 | 9 | **Project has been deprecated. Instead you shound be using the [Contacts framework](https://developer.apple.com/library/prerelease/mac/documentation/Contacts/Reference/Contacts_Framework/index.html#//apple_ref/doc/uid/TP40015328)** 10 | 11 | ## Installation 12 | 13 | ### [CocoaPods](http://cocoapods.org) 14 | 15 | ```ruby 16 | platform :ios, '6.0' 17 | pod 'AFAddressBookManager', '~> 1.2' 18 | ``` 19 | 20 | ### Manually 21 | 22 | Copy all files from AFAddressBookManager folder to your project and add the [Address Book framework](http://developer.apple.com/library/ios/#documentation/AddressBook/Reference/AddressBook_iPhoneOS_Framework/). 23 | 24 | ## Usage 25 | 26 | Import `AFAddressBookManager.h` in the class where you want to use it. 27 | 28 | ### Available methods 29 | 30 | Get name (first and last) of contact by phone number: 31 | ```objectivec 32 | + (NSString *)nameForContactWithPhoneNumber:(NSString *)phoneNumber; 33 | ``` 34 | 35 | Get photo of contact by phone number: 36 | ```objectivec 37 | + (UIImage *)photoForContactWithPhoneNumber:(NSString *)phoneNumber; 38 | ``` 39 | 40 | Get name (first and last) of contact by email address: 41 | ```objectivec 42 | + (NSString *)nameForContactWithEmailAddress:(NSString *)emailAddress; 43 | ``` 44 | 45 | Get photo of contact by email address: 46 | ```objectivec 47 | + (UIImage *)photoForContactWithEmailAddress:(NSString *)emailAddress; 48 | ``` 49 | 50 | 51 | ## Other iOS Open Source Projects by Me 52 | 53 | - [AFWebViewController](https://github.com/Fogh/AFWebViewController) 54 | - [AFMobilePayRequestHandler](https://github.com/Fogh/AFMobilePayRequestHandler) 55 | --------------------------------------------------------------------------------