设置 kABPersonType

发布于 2024-11-06 15:34:54 字数 648 浏览 8 评论 0原文

我正在尝试设置联系人的 kABPersonType 值(ABAddressBook iOS)。

ABRecordSetValue(person, kABPersonType, [currentContact personType], nil);//person type (individual or company

[currentContact personType] 是一个 NSNumber。

当我们到达 ABAddressBookSave 时会抛出错误。

如下;

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFNumber length]: unrecognized selector sent to instance 0x6805ff0'

在所有其他情况下;例如

ABRecordSetValue(person, kABPersonNoteProperty, [currentContact note], nil);

属性设置没问题。

有什么想法为什么会发生这种情况吗?

干杯,

丰富

I'm trying to set the kABPersonType value for a contact (ABAddressBook iOS).

ABRecordSetValue(person, kABPersonType, [currentContact personType], nil);//person type (individual or company

[currentContact personType] is an NSNumber.

An error gets thrown when we reach ABAddressBookSave.

As follows;

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFNumber length]: unrecognized selector sent to instance 0x6805ff0'

In all other cases; e.g.

ABRecordSetValue(person, kABPersonNoteProperty, [currentContact note], nil);

The setting of properties is fine.

Any ideas why this is happening?

Cheers,

Rich

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

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

发布评论

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

评论(1

十级心震 2024-11-13 15:34:54

您无法设置记录的记录类型。记录类型由您创建的记录类型(ABPersonCreate()ABGroupCreate())决定,并且以后无法更改。

如果您打算设置人员记录 kind (个人或公司),则必须使用正确的常量:kABPersonKindProperty 作为第二个参数,并且值参数 ( NSNumber) 必须包含 kABPersonKindPerson

You cannot set a record's record type. The record type is determined by the type of record you create (ABPersonCreate() or ABGroupCreate()) and cannot be changed later.

If you mean to set the person record kind (to person or company) instead, you have to use the correct constants: kABPersonKindProperty as the second argument, and the value argument (NSNumber) must contain kABPersonKindPerson.

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