|Version 4 (modified by rme, 6 years ago) (diff)|
Using the Address Book framework
Here's a bare-bones example of how to load and use the Address Book framework.
? (require 'objc-support) OBJC-SUPPORT ("OBJC-PACKAGE" "SEQUENCE-UTILS" "NAME-TRANSLATION" "OBJC-CLOS" "OBJC-RUNTIME" "BRIDGE" "OBJC-SUPPORT") ;;; Load the framework ? (objc:load-framework "AddressBook" :addressbook) NIL ;;; Looks like it worked... ? ns:ab-address-book #<AB-ADDRESS-BOOK <ABAddressBook: 0x1743c300> (#x1743C300)>
Load this code (after doing the OBJC:LOAD-FRAMEWORK mentioned above), and you'll be able to say (absearch "smith") to look for the Smiths in your Address Book. Note that the output from NSLog may go to the system console.
(in-package "CCL") (defun absearch (surname) (let* ((ab (#/sharedAddressBook ns:ab-address-book)) (search (#/searchElementForProperty:label:key:value:comparison: ns:ab-person #&kABLastNameProperty +null-ptr+ +null-ptr+ (#/autorelease (%make-nsstring surname)) #$kABEqualCaseInsensitive)) (results (#/recordsMatchingSearchElement: ab search))) (#_NSLog #@"%@" :id results)))