Ios 使用地址簿筛选已知电话号码的用户联系人列表

Ios 使用地址簿筛选已知电话号码的用户联系人列表,ios,objective-c,abaddressbook,Ios,Objective C,Abaddressbook,不管出于什么原因,我在任何地方都找不到这个,但我正在编写一个iphone应用程序,并试图 使用ABAddressBook框架过滤已知电话号码的用户联系人列表 我想将联系人列表(一个UITableViewController)分为两个部分:应用程序中已有的联系人和应用程序中没有的联系人。我将联系人列表存储在NSArray中,我需要弄清楚如何确定数组中的联系人是否已经在应用程序中 完成此操作后,我需要能够将已在使用应用程序部分的联系人添加到“好友列表”UITableViewController 非常

不管出于什么原因,我在任何地方都找不到这个,但我正在编写一个iphone应用程序,并试图 使用
ABAddressBook
框架过滤已知电话号码的用户联系人列表

我想将联系人列表(一个
UITableViewController
)分为两个部分:应用程序中已有的联系人和应用程序中没有的联系人。我将联系人列表存储在NSArray中,我需要弄清楚如何确定数组中的联系人是否已经在应用程序中

完成此操作后,我需要能够将已在使用应用程序部分的联系人添加到“好友列表”
UITableViewController

非常感谢你

以下是我的.m文件代码:

    - (void)viewDidLoad
    {
[super viewDidLoad];

self.contacts = [[NSArray alloc]init];
[self getAllContacts];

// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;

// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;

//GETS RID OF WEIRD OVERLAP BUG ON TABLE VIEW CONTROLLER
[self.navigationController.view setBackgroundColor:[UIColor whiteColor]];
    }

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

// Return the number of rows in the section.
return self.contacts.count;
}

-(void)getAllContacts
{
APAddressBook *addressBook = [[APAddressBook alloc]init];
addressBook.fieldsMask = APContactFieldAll;
addressBook.filterBlock = ^BOOL(APContact *contact){
    return (contact.phones.count > 0) && !(contact.firstName == nil && contact.lastName     == nil);
};

[addressBook loadContacts:^(NSArray *apContacts, NSError *error) {
    if(!error){
        NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
        for (APContact *AP in apContacts) {
            Contact *contact = [Contact new];
            contact.firstName = AP.firstName?[AP.firstName stringByAppendingString:@"   "]:@"";
            contact.lastName = AP.lastName?AP.lastName:@" ";
            contact.fullName = [contact.firstName   stringByAppendingString:contact.lastName];
            if(AP.emails && [AP.emails count] > 0) {
                contact.email = [AP.emails firstObject]?:nil;
            }

            if(AP.thumbnail ) {
                contact.image = AP.thumbnail;
            } else {
              /*  contact.image = [UIImage imageNamed:]; ADD GENERIC DEFAULT IMAGE*/
            }
            if(AP.phones && [AP.phones count] > 0) {
                NSString *phone = [AP.phones firstObject];
                contact.phoneNumber = [NSString formatNumber:phone];
                contact.numberToDisplay = phone;
                contact.identifier = [NSString formatNumber:phone];
            } /*else {
                contact.identifier = [AP.emails firstObject];

        }*/
            [dic setValue:contact forKey:contact.fullName];
        }

        self.contacts = [dic allValues];

        [self setupContacts];

    } else {
        //write an alert error.description
    }


 }];

}

-(void)setupContacts{

NSSortDescriptor *descriptor = [[NSSortDescriptor alloc]initWithKey:@"fullName"   ascending:YES selector:@selector(caseInsensitiveCompare:)];

NSArray *descriptors = [NSArray arrayWithObject:descriptor];
self.contacts = [self.contacts sortedArrayUsingDescriptors:descriptors];

if (!self.selectedContacts) {
    self.selectedContacts = [[NSMutableDictionary  alloc]initWithCapacity:self.contacts.count];
}
self.tableView.allowsSelection = YES;
self.tableView.allowsMultipleSelection = YES;

 [self.tableView reloadData];

}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:  (NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"ContactsCell";
ContactsCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

// Configure the cell...
if (cell == nil) {
    cell = (ContactsCell *)[[ContactsCell alloc]  initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}

NSInteger row = indexPath.row;
Contact *contact = [self.contacts objectAtIndex:row];
cell.mainTextLabel.text = contact.fullName;

cell.hidden = NO;

return cell;
}

这与Xcode无关。这个问题非常模糊。您所描述的内容需要一个后端服务来存储用户的联系信息以进行比较。