设置 kABPersonType
我正在尝试设置联系人的 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法设置记录的记录类型。记录类型由您创建的记录类型(
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()
orABGroupCreate()
) 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 containkABPersonKindPerson
.