0

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

Shadrax
  • 57
  • 1
  • 9

1 Answers1

0

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.

Ole Begemann
  • 135,006
  • 31
  • 278
  • 256