iOS 文档地址簿编程指南的一个奇怪问题

发布于 2025-01-05 09:56:56 字数 1031 浏览 1 评论 0 原文

我正处于 iOS 编程的初级水平。我正在使用 Xcode 4.2 和 iOS Simulator 5.0。 我正在使用 iOS 文档 地址制作快速入门教程应用程序书籍编程指南,我正在遵循教程的所有步骤,但我在这段代码中遇到了一个奇怪的错误:

-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person
{
    NSString *name;
    name = (NSString *) ABRecordCopyValue(person, kABPersonFirstNameProperty);
    self.firstName.text=name;

    name=( NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty);
    self.lastName.text=name;
    [self dismissModalViewControllerAnimated:YES];
    return NO;
}

at line:

name = (NSString *) ABRecordCopyValue(person, kABPersonFirstNameProperty);

I get the error Cast of C point type 'CFTypeRef'(又名'const void *')到 Objective-C 指针类型'NSString *'需要桥接转换

我在这里做错了什么?

I am at a beginner level of iOS programming. I am using Xcode 4.2 with iOS Simulator 5.0.
I am making the quick start tutorial app using iOS documentation Address Book programming Guide and I'm following all the steps of the tutorial but I get a strange error in this code:

-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person
{
    NSString *name;
    name = (NSString *) ABRecordCopyValue(person, kABPersonFirstNameProperty);
    self.firstName.text=name;

    name=( NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty);
    self.lastName.text=name;
    [self dismissModalViewControllerAnimated:YES];
    return NO;
}

at line:

name = (NSString *) ABRecordCopyValue(person, kABPersonFirstNameProperty);

I get the error Cast of C pointer type 'CFTypeRef' (aka 'const void *') to Objective-C pointer type 'NSString *' requires a bridged cast

What am I doing wrong here ?

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

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

发布评论

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

评论(1

时常饿 2025-01-12 09:56:56

请查看 此链接已更新为最新版本:

NSString* name = (__bridge_transfer NSString*)ABRecordCopyValue(person,
                                           kABPersonFirstNameProperty);

NSString* name = (__bridge NSString*)ABRecordCopyValue(person,
                                           kABPersonFirstNameProperty);

Please check out this link which has been updated with the latest:

NSString* name = (__bridge_transfer NSString*)ABRecordCopyValue(person,
                                           kABPersonFirstNameProperty);

or

NSString* name = (__bridge NSString*)ABRecordCopyValue(person,
                                           kABPersonFirstNameProperty);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文