orthehelper
orthehelper

Reputation: 4079

accessing kABPersonURLProperty from address book

I am trying to access kABPersonHomePageLabel. From my understanding first i have to access a dictionary generated by calling this property kABPersonURLProperty as i did below. when i am NSloging the web instance i get this log :

2013-10-09 20:49:04.823 contacts[1303:907] _$!<HomePage>!$_

ABMultiValueRef websites = ABRecordCopyValue((__bridge ABRecordRef)record, kABPersonURLProperty);
if (ABMultiValueGetCount(websites) > 0) {
    NSLog(@"BBIIGGEERR");
    CFStringRef web = ABMultiValueCopyLabelAtIndex(websites,0);
    NSLog(@"%@",web);
}

I know i have a home url in this particular contact, but how can i extract the url?

Upvotes: 1

Views: 370

Answers (1)

Toseef Khilji
Toseef Khilji

Reputation: 17409

You have to search in All ABMultiValueRef values, like this

Update

    ABMultiValueRef websites = ABRecordCopyValue((__bridge ABRecordRef)record, kABPersonURLProperty);
    NSUInteger i = 0;
    for (i = 0; i < ABMultiValueGetCount(websites); i++)
            {
                NSString *eml = (__bridge_transfer NSString *)ABMultiValueCopyLabelAtIndex(websites, i);
                if([eml isEqualToString:(NSString *) kABPersonHomePageLabel]) {
                    NSString *web = (__bridge_transfer NSString *)ABMultiValueCopyValueAtIndex(websites, i);
                    NSLog(@"%@",web);
                }
            }

Upvotes: 2

Related Questions