0

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

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

属性设置没问题。

任何想法为什么会发生这种情况?

干杯,

富有的

4

1 回答 1

0

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

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

于 2011-05-11T14:31:51.970 回答