Question

I'm trying to access the homepages/websites from the users contacts on a iPad. I'm actually trying to modify an existing script that is used as a Native Extension for Adobe Air - https://github.com/memeller/ContactEditor/blob/master/ContactEditorXCode/ContactEditor.m

I'm very new to Objective-C/xCode so I'm really struggling get this extra field returned... Please can you someone help me out.

FREObject homepagesArray = NULL;
FRENewObject((const uint8_t*)"Array", 0, NULL, &homepagesArray, nil);
ABMultiValueRef homepages = ABRecordCopyValue(person, kABPersonHomePageLabel);
if(homepages)
{
    for (CFIndex k=0; k < ABMultiValueGetCount(homepages); k++) {
        NSString* homepage = (__bridge NSString*)ABMultiValueCopyValueAtIndex(homepages, k);
        DLog(@"Adding homepage: %@",homepage);
        FRENewObjectFromUTF8(strlen([homepage UTF8String])+1, (const uint8_t*)[homepage UTF8String], &retStr);
        FRESetArrayElementAt(homepagesArray, k, retStr);
        //[email release];
    }
    CFRelease(homepages);
    FRESetObjectProperty(contact, (const uint8_t*)"homepages", homepagesArray, NULL);
}
else
    FRESetObjectProperty(contact, (const uint8_t*)"homepages", NULL, NULL);
retStr=NULL;
Was it helpful?

Solution

You're using the wrong identifier for extracting ABMultiValueRef homepages. Use the kABPersonURLProperty identifier instead of kABPersonHomePageLabel, e.g.

ABMultiValueRef webpages = ABRecordCopyValue(person, kABPersonURLProperty);

// Then iterate thru webpages to get the homepage
for (CFIndex k=0; k < ABMultiValueGetCount(webpages); k++)
{
    // Your code here
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top