Skip to content

Commit

Permalink
Added dump_mac_addressbook.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Jun 21, 2016
1 parent b482219 commit 7a4c25b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Binary file added dump_mac_addressbook
Binary file not shown.
37 changes: 37 additions & 0 deletions dump_mac_addressbook.m
@@ -0,0 +1,37 @@
#include <stdio.h>
#include <AddressBook/AddressBook.h>

static void print_propstr(const char *str)
{
printf("%s\n", str ? str : "");
}

int main(int argc, char **argv)
{
@autoreleasepool {
int idx = 0;

NSArray *list = [[ABAddressBook sharedAddressBook] people];

for (ABPerson *person in list) {
print_propstr([[person valueForProperty:kABNicknameProperty] cStringUsingEncoding:NSUTF8StringEncoding]);
print_propstr([[person valueForProperty:kABFirstNameProperty] cStringUsingEncoding:NSUTF8StringEncoding]);
print_propstr([[person valueForProperty:kABMiddleNameProperty] cStringUsingEncoding:NSUTF8StringEncoding]);
print_propstr([[person valueForProperty:kABLastNameProperty] cStringUsingEncoding:NSUTF8StringEncoding]);
static NSString *props[] = { @"Phone", @"Email", nil };
for (int propidx = 0; props[propidx] != nil; propidx++) {
ABMultiValue *mval = [person valueForProperty:props[propidx]];
const int total = [mval count];
for (int i = 0; i < total; i++) {
NSString *nsstr = [mval valueAtIndex:i];
printf("%s\n", [nsstr cStringUsingEncoding:NSUTF8StringEncoding]);
}
printf("\n");
}
}
}

return 0;
}

// end of dump_mac_addressbook.m ...

0 comments on commit 7a4c25b

Please sign in to comment.