LWContactManager
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
-(LWAddressBookService *)addressBookService{
if(!_addressBookService){
_addressBookService = [[LWAddressBookService alloc] init];
}
return _addressBookService;
}
//联系人列表
- (void)reloadSearchAddressBook {
__weak typeof(self) weakSelf = self;
[self.addressBookService requestAccess:^(BOOL granted, NSError *error) {
__strong typeof(self) strongSelf = weakSelf;
if (granted) {
NSString *searchText = [strongSelf searchText];
[strongSelf.addressBookService
loadContactsWithSearchText:searchText
successBlock:^(NSArray<APContact *> *contacts, NSError *err) {
[strongSelf setContacts:contacts];
[strongSelf reloadData];
[strongSelf.collectionViewLayout invalidateLayout];
}];
}
}];
}
Requirements
Installation
LWContactManager is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'LWContactManager'
Carthage
github "luowei/LWContactManager"
Usage
-(LWAddressBookService *)addressBookService{
if(!_addressBookService){
_addressBookService = [[LWAddressBookService alloc] init];
}
return _addressBookService;
}
//重新搜索联系人列表
- (void)reloadSearchAddressBook {
__weak typeof(self) weakSelf = self;
[self.addressBookService requestAccess:^(BOOL granted, NSError *error) {
__strong typeof(self) strongSelf = weakSelf;
if (granted) {
NSString *searchText = [strongSelf searchText];
[strongSelf.addressBookService
loadContactsWithSearchText:searchText
successBlock:^(NSArray<APContact *> *contacts, NSError *err) {
for(APContact *contact in contacts){
NSLog(@"==== name:%@ %@ phone:%@",contact.name.lastName,contact.name.firstName,contact.phones.firstObject.number);
}
//todo:设置联系人
}];
}
}];
}
- (NSString *)searchText {
return @"李";
}
Author
luowei, luowei@wodedata.com
License
LWContactManager is available under the MIT license. See the LICENSE file for more info.