从 ABRecordRef 检索即时消息信息
我正在尝试从 iOS 上现有的 AddressBook
联系人获取即时消息帐户信息。我浏览联系人并获得具有即时消息传递价值的联系人,但我无法读取 jabber 地址。
abArray = (NSArray *)ABAddressBookCopyArrayOfAllPeople(ABAddressBookCreate());
for(int i=0 ; i<[abArray count];i++)
{
ABRecordRef record = [abArray objectAtIndex:i];
ABMutableMultiValueRef multi = ABRecordCopyValue(record, kABPersonInstantMessageProperty);
for(CFIndex x=0;x<ABMultiValueGetCount(multi);x++)
{
CFDictionaryRef dict = ABMultiValueCopyValueAtIndex(multi, x);
CFStringRef jabber = CFDictionaryGetValue(dict, kABPersonInstantMessageServiceJabber);
if(CFDictionaryContainsKey(dict, kABPersonInstantMessageServiceJabber))
{
NSLog(@"yes");
}
else {
NSLog(@"no");
}
// only to make it possible to log to console
NSString *jaab = (NSString *)jabber;
NSLog(@"jabber adress: %@" , jaab);
}
CFRelease(dict);
}
}
我做错了什么?
I'm trying to get the instant message account information from existing AddressBook
contacts on iOS. I walk through the contacts and I get the contacts which have an instant messaging value, but I can't read the jabber-address.
abArray = (NSArray *)ABAddressBookCopyArrayOfAllPeople(ABAddressBookCreate());
for(int i=0 ; i<[abArray count];i++)
{
ABRecordRef record = [abArray objectAtIndex:i];
ABMutableMultiValueRef multi = ABRecordCopyValue(record, kABPersonInstantMessageProperty);
for(CFIndex x=0;x<ABMultiValueGetCount(multi);x++)
{
CFDictionaryRef dict = ABMultiValueCopyValueAtIndex(multi, x);
CFStringRef jabber = CFDictionaryGetValue(dict, kABPersonInstantMessageServiceJabber);
if(CFDictionaryContainsKey(dict, kABPersonInstantMessageServiceJabber))
{
NSLog(@"yes");
}
else {
NSLog(@"no");
}
// only to make it possible to log to console
NSString *jaab = (NSString *)jabber;
NSLog(@"jabber adress: %@" , jaab);
}
CFRelease(dict);
}
}
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)