The AddressBook framework has a list of constants, like kABFirstNameProperty
. I'm wondering if there's a list of those that I could display in a user interface, other than having to "replicate" this myself?
Asked
Active
Viewed 212 times
0

StuFF mc
- 4,137
- 2
- 33
- 32
2 Answers
1
In the C-based Address Book API for the Mac, there's a function named ABCopyArrayOfPropertiesForRecordType
that sounds like exactly what you need.
I would hope that the property keys would be equal to those in the Objective-C AB API, if that's what you're using, but you should probably test that—or just use the C-based API.

Peter Hosey
- 95,783
- 15
- 211
- 370
-
Nope. Not what I'm looking for. I'm looking for a list of "all" properties, not only those set for a contact. – StuFF mc Jun 02 '12 at 16:23
-
1@StuFFmc: The function is “…ForRecord*Type*”. It gives you all properties that are possible for records of the specified type (e.g., ABPerson). – Peter Hosey Jun 02 '12 at 16:46
-
Oh. Sorry. Yeah that function doesn't seem to have been implemented in ObjC. I don't mind using the C function but although it works in the Console, in the code, the compiler complains it doesn't know `kAbPersonRecordType`. Any idea? – StuFF mc Jun 03 '12 at 19:19
-
Not **yet** marking it as the *answered* because I'm not yet 100% sure it's the right thing. Here's what it gives back: `(lldb) po (NSArray*) ABCopyArrayOfPropertiesForRecordType(ab, kABPersonRecordType) (NSArray *) $1 = 0x00000001005ca830 <__NSArrayI 0x1005ca830>( com.apple.Messages.FontSize, com.apple.etag, HomePage, InstantMessage, AIMInstant, First, YahooInstant, ICQInstant, Address, JobTitle, Creation, ABPersonFlags, BirthdayComponents, Email, ABRelatedNames, MSNInstant, Modification, ABDepartment, RemoteLocation, com.apple.collectionpath, Middle, ..., FirstPhonetic, ABDateComponents )` – StuFF mc Jun 03 '12 at 20:01
-
So yeah I marked it as **answered** now, but I still have a problem with the way I would identify the `com.apple.***` (which are `__NSCFString`) and the `__NSCFConstantString` (which are *real* properties). One way is checking if the returned value from `ABLocalizedPropertyOrLabel` is the same, but it's not super awesome. In any cases, Peter, THANKS for the pointer! – StuFF mc Jun 03 '12 at 23:03
-
@StuFFmc: `kABPersonRecordType` is declared in the headers for the C API, and it looks like AddressBook.h “intelligently” only includes one set of headers or the other, according to your module's language (if you're writing in Objective-C, it imports the Objective-C headers). You'd have to import ABGlobalsC.h directly. I found a better solution, though—see my new other answer. – Peter Hosey Jun 04 '12 at 01:20
1
I just found the Objective-C API's equivalents to the ABCopyArrayOfPropertiesForRecordType
function. Two methods:
Since these are class methods, you should find that they return all known properties for any records of that type.

Peter Hosey
- 95,783
- 15
- 211
- 370