AddressBook:如何获取不同 Exchange 源的名称
我想要获取我的 iPhone 同步到的所有 Exchange 源的名称。例如,如果我使用 ActiveSync Exchange 将我的设备同步到 Gmail 和 Hotmail 帐户,则在本机联系人中,我可以根据我设置的不同帐户看到不同的部分。当我尝试以编程方式执行相同操作时,我获得的唯一信息是 sourceType(在这两种情况下都是 Exchange)和 sourceName(在这两种情况下都是“Contacts”)。我无法区分哪个是 Gmail“联系人”,哪个是 Hotmail“联系人”。
有人知道该怎么做吗?这是我的代码:
CFArrayRef allSources = ABAddressBookCopyArrayOfAllSources(book);
for (CFIndex i = 0; i < CFArrayGetCount(allSources); i++) {
ABRecordRef source = (ABRecordRef)CFArrayGetValueAtIndex(allSources, i);
NSString *sourceTypeName = (NSString *)((CFStringRef)ABRecordCopyValue(source, kABSourceNameProperty));
NSLog(@"%@", sourceTypeName);
}
I want to get the name of all the Exchange sources that my iPhone is synced to. For e.g. if I sync my device to Gmail and Hotmail accounts using ActiveSync Exchange, in the native contacts, I can see different sections based on the different accounts that I have setup. When I try to programmatically do the same, the only information I get is sourceType (which is Exchange in both cases) and sourceName (which is "Contacts" in both cases). There's no way for me to differentiate which is the Gmail "Contacts" and which is the Hotmail "Contacts".
Anyone know how to do this? Here's my code:
CFArrayRef allSources = ABAddressBookCopyArrayOfAllSources(book);
for (CFIndex i = 0; i < CFArrayGetCount(allSources); i++) {
ABRecordRef source = (ABRecordRef)CFArrayGetValueAtIndex(allSources, i);
NSString *sourceTypeName = (NSString *)((CFStringRef)ABRecordCopyValue(source, kABSourceNameProperty));
NSLog(@"%@", sourceTypeName);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你似乎还不能在 iOS 中做到这一点
You can't do this in iOS it seems (yet)