1

AddressBookiOSの既存の連絡先からインスタント メッセージのアカウント情報を取得しようとしています。連絡先を調べて、インスタント メッセージの値を持つ連絡先を取得しましたが、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);
  }
}

私は何を間違っていますか?

4

1 に答える 1

0
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;


        //Use this piece of code to print the dict to log and check

        NSDictionary *nsdict = (NSDictionary *)dict;
        NSString *jabberID = [NSString stringWithString:@""];
        NSLog(@"Dict: %@", nsdict);
        if([[nsdict valueForKey:@"service"] isEqualToString:@"Jabber"]){
            jabberID = [nsdict valueForKey:@"username"];
        }
        //Code to print dict to log ends here. Comment the whole piece if not needed.


        if(CFStringCompare((CFStringRef)@"jabber", CFDictionaryGetValue(dict, @"service"), 0))
        {
            NSLog(@"yes");
            jabber = CFDictionaryGetValue(dict, @"username");

            // only to make it possible to log to console  
            NSString *jaab = (NSString *)jabber;
            NSLog(@"jabber adress: %@" , jaab);
        }
        else {
            NSLog(@"no");
        }

    }
    //CFRelease(dict);
}
于 2010-03-26T14:33:10.350 に答える