0

我正在尝试从 iPad 上的用户联系人访问主页/网站。我实际上是在尝试修改用作 Adob​​e Air 原生扩展的现有脚本 - https://github.com/memeller/ContactEditor/blob/master/ContactEditorXCode/ContactEditor.m

我对 Objective-C/xCode 很陌生,所以我真的很难让这个额外的字段返回......请有人帮帮我。

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

1 回答 1

0

您使用了错误的标识符来提取ABMultiValueRef homepages. 使用kABPersonURLProperty标识符而不是kABPersonHomePageLabel,例如

ABMultiValueRef webpages = ABRecordCopyValue(person, kABPersonURLProperty);

// Then iterate thru webpages to get the homepage
for (CFIndex k=0; k < ABMultiValueGetCount(webpages); k++)
{
    // Your code here
}
于 2014-02-10T02:03:08.333 回答