在 iPhone 的 Objective C 中导入 VCard

发布于 2024-12-18 10:59:23 字数 955 浏览 2 评论 0原文

我正在使用 XCode 4.2 开发一个 iPhone 应用程序。在该应用程序的一部分中,我将获得一个 VCard 作为 NSString

我发现这个函数 initWithVCardRepresentation 并且我认为它比解析数据更容易一个(即先获取名字,然后获取姓氏等...,但我很难在我的代码中实现它。

我有 AddressBookAddressBookUI 框架,我正在尝试使用此代码,但在编译时找不到确切的方法

-(IBAction)Add{

  // I have a  NSString *card defined somewhere else
   ABAddressBookRef *iPhoneAddressBook = ABAddressBookCreate();
    ABRecordRef *contact = ABPersonCreatePeopleInSourceWithVCardRepresentation(iPhoneAddressBook, (__bridge_retained CFStringRef) card);

    CFRelease(contact);
    CFRelease(iPhoneAddressBook);   
}

,它崩溃了 ABRecordRef *contact = ABPersonCreatePeopleInSourceWithVCardRepresentation(iPhoneAddressBook, (__bridge_retained CFStringRef) card); 我在 @autoreleasepool 中收到以下绿色错误

Thread1:Program Received Signal "SIGABRT".

我对应用程序开发很陌生,请告诉我我提供的信息是否足够

谢谢

I am developping an iPhone App using XCode 4.2 .in a portion of the App I will be getting a VCard as an NSString

I found this function initWithVCardRepresentation and i think it will be easier than parsing the data one by one (i.e getting the first name then the last name etc ... , but I have a hard time to implement it in my code .

I have the AddressBook and the AddressBookUI frameworks and I am trying to use this code but can t find an exact way to do it

-(IBAction)Add{

  // I have a  NSString *card defined somewhere else
   ABAddressBookRef *iPhoneAddressBook = ABAddressBookCreate();
    ABRecordRef *contact = ABPersonCreatePeopleInSourceWithVCardRepresentation(iPhoneAddressBook, (__bridge_retained CFStringRef) card);

    CFRelease(contact);
    CFRelease(iPhoneAddressBook);   
}

when I compile ,it crashes at the line
ABRecordRef *contact = ABPersonCreatePeopleInSourceWithVCardRepresentation(iPhoneAddressBook, (__bridge_retained CFStringRef) card);
and I get the following green error in the @autoreleasepool

Thread1:Program Received Signal "SIGABRT".

I am quite new to the Apps development , please let me know if the information I gave is sufficient

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

叹沉浮 2024-12-25 10:59:23

如果您之后想拥有一个 ABPerson(建议),请使用:

// Assuming NSString *card exists already.
ABPerson *person = [[[ABPerson alloc] initWithVCardRepresentation:[card dataUsingEncoding:NSUTF8StringEncoding] autorelease];

If you want to have an ABPerson afterwards (what is advisable), use:

// Assuming NSString *card exists already.
ABPerson *person = [[[ABPerson alloc] initWithVCardRepresentation:[card dataUsingEncoding:NSUTF8StringEncoding] autorelease];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文