iOS 7.0
要运行示例项目;克隆仓库,运行 pod install
,然后打开 JLAddressBookExample.xcworkspace。
您需要创建一个符合此协议的实体类型
@protocol JLContact<NSObject>
@optional
@property(nonatomic, strong) NSString *firstName;
@property(nonatomic, strong) NSString *lastName;
@property(nonatomic, strong) NSArray *phoneNumbers; // NSString's
@property(nonatomic, strong) NSArray *emails; // NSString's
@property(nonatomic, strong) NSArray *addressBookIDs; // NSNumbers's
@property(nonatomic, strong) UIImage *thumbnail;
@property(nonatomic, strong) UIImage *photo;
@end
然后使用 JLCoreDataContactManager 或定义一个联系人管理器来跟踪这些实体
@protocol JLContactManager<NSObject>
@required
- (id<JLContact>)newContact;
- (NSArray *)existingContacts;
@end
然后您调用 JLAddressBook syncContacts 以更新您的联系人信息
@interface JLAddressBook : NSObject
- (instancetype)initWithContactManager:(id<JLContactManager>)contactManager;
+ (BOOL)authorized;
+ (void)attemptToAuthorize:(AuthorizationBlock)block;
- (NSArray *)syncContacts;
- (UIImage *)photoForContact:(id<JLContact>)contact;
- (UIImage *)thumbnailForContact:(id<JLContact>)contact;
- (void)addContactToDevice:(id<JLContact>)contact;
- (void)addContactToDevice:(id<JLContact>)contact withPhoto:(UIImage *)photo;
@end
以下是一些使用这个库的 iPhone 应用程序列表
JLAddressBook 可在 MIT 许可证下使用。有关更多信息,请参阅 LICENSE 文件。