phonenumber值是
(
(
9834677334
),
(
9977655456
),
(
9976367777
),
(
9654567877
),
(
9834777347
),
(
9994157837
),
(
9978855544
),
(
9873667378
)
)
代码
- (void)parseContactWithContact :(CNContact* )contact {
NSString * firstName = contact.givenName;
NSLog(@"The firstName value is %@",firstName);
[tableData addObject:firstName];
NSString * items = [[contact.phoneNumbers valueForKey:@"value"] valueForKey:@"digits"];
NSLog(@"The phone value is %@",items);
[phonenumber addObject:items];
NSString * email = [contact.emailAddresses valueForKey:@"value"];
NSLog(@"The email value is %@",email);
NSArray * addrArr = [self parseAddressWithContac:contact];
}
我已经获取了所有联系人记录...我得到了一个电话号码值,上面提到过,我的问题是,我不知道如何访问数组值....当我想要存储它时一个数组并填入tableview,我收到一个错误,我只能访问第一个值..可以任何人帮我如何访问和填充到tableview
答案 0 :(得分:0)
试试这个
NSString * items = [[contact.phoneNumbers valueForKey:@"value"] valueForKey:@"digits"];
NSLog(@"The phone value is %@",items);
[phonenumber addObject:items];
删除电话号码中的特殊字符()
,并将字符串附加到phonenumber
数组并填充到您的表格
例如
NSString * items = [[contact.phoneNumbers valueForKey:@"value"] valueForKey:@"digits"];
NSCharacterSet *filterstr = [[NSCharacterSet characterSetWithCharactersInString:@"1234567890"] invertedSet];
NSString *resultString = [[items componentsSeparatedByCharactersInSet:filterstr] componentsJoinedByString:@""];
[phonenumber addObject:items];
.... continue your same work ...
您将电话号码数组视为