无法将 ABPerson 添加到 ABGroup。没有错误,只是不会实际添加
嘿,我正在尝试将 ABPerson 添加到 ABGroup。我没有得到任何错误或任何东西。我的输出告诉我该人已成功添加。
if(ABGroupAddMember(self.group, [allContacts objectAtIndex:indexPath.row], &error))
NSLog(@"Added person: %@ to group: %@", ABRecordCopyCompositeName([allContacts objectAtIndex:indexPath.row]), ABRecordCopyCompositeName(self.group));
if(ABAddressBookSave(self.addressBook, &error))
NSLog(@"Commited changes.");
这两个语句返回正确的输出。
但在查询组成员时,我得到一个空数组。
NSLog(@"%@", ABGroupCopyArrayOfAllMembers(self.group)); //returns null
如果有人有任何想法,我将非常感激。
Hey I'm trying to add an ABPerson to an ABGroup. I get no errors or anything. My output tells me the person has been added successfully.
if(ABGroupAddMember(self.group, [allContacts objectAtIndex:indexPath.row], &error))
NSLog(@"Added person: %@ to group: %@", ABRecordCopyCompositeName([allContacts objectAtIndex:indexPath.row]), ABRecordCopyCompositeName(self.group));
if(ABAddressBookSave(self.addressBook, &error))
NSLog(@"Commited changes.");
These two statements return the correct output.
But upon querying the group members, I get an empty array.
NSLog(@"%@", ABGroupCopyArrayOfAllMembers(self.group)); //returns null
If anybody has any ideas, I'd really appreciate it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
哇,发帖后不到5分钟,我就发现了问题。编辑群组后,我必须将其添加回地址簿,如下所示:
Wow not 5 minutes after posting, I've found the problem. After editing the group, I have to add it back to the address book like so:
仅供参考,某些源(ABSource,例如 MSExchange)不支持组创建。
这里有一些关于指定源的详细信息和代码示例(仅限 iOS 4+):
在 iOS 4+ 中从 ABAddressBook 获取特定 ABSource
Just as an FYI, some sources (ABSource, e.g. MSExchange) do not support group creation.
There are some details and code examples on specifying sources (iOS 4+ only) here:
Obtaining Specific ABSource from ABAddressBook in iOS 4+