如何获取保存在联系人中的所有组名?以下是我的代码供您参考:
NSMutableArray *list = [NSMutableArray array];
ABAddressBookRef myAddressBook = ABAddressBookCreate();
CFArrayRef allSources = ABAddressBookCopyArrayOfAllGroups(myAddressBook);
list = [NSMutableArray arrayWithArray: (__bridge NSArray*) allSources];
NSLog(@"GROUPS %@",[list objectAtIndex:0]);
NSLog返回a但我需要自己获取组名。
感谢。
答案 0 :(得分:2)
使用ABRecordCopyCompositeName()
功能。
ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, NULL);
if (addressBook != NULL) {
ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) {
if (granted) {
CFArrayRef allGroups = ABAddressBookCopyArrayOfAllGroups(addressBook);
if (allGroups != NULL) {
NSMutableArray *names = [NSMutableArray array];
for (int i = 0; i < CFArrayGetCount(allGroups); i++) {
ABRecordRef group = CFArrayGetValueAtIndex(allGroups, i);
CFStringRef name = ABRecordCopyCompositeName(group);
[names addObject:(__bridge NSString *)name];
CFRelease(name);
}
NSLog(@"names = %@", names);
CFRelease(allGroups);
}
}
CFRelease(addressBook);
});
}
答案 1 :(得分:0)
这对我有用:
Error:(36, 102) type mismatch;
found : T
required: String
def +(that: Vector[T]): Vector[T] = new VectorImpl[T](_data.zip(that).map(elem => elem._1 + elem._2))
^
Error:(37, 95) value - is not a member of type parameter T
def -(that: Vector[T]): Vector[T] = new VectorImpl[T](_data.zip(that).map(elem => elem._1 - elem._2))
^