0
如何在JavaScript for Automation中使用ObjC橋接接口框架?我可以使用舊的AddressBook框架,但不能使用聯繫人。在JavaScript中使用objC橋接自動化框架
比方說,我有一個ID:
id = Application("Contacts").myCard().id()
舊通訊錄框架正常工作:
ObjC.import("AddressBook");
book = $.ABAddressBook.addressBook
person = book.recordForUniqueId(id)
console.log(person.valueForProperty($.kABFirstNameProperty).js)
但如何使用聯繫人框架? 我試圖(基於對unifiedContactWithIdentifier
文件上):
ObjC.import('Contacts')
keysToFetch = [ $.CNContactGivenNameKey, $.CNContactFamilyNameKey ]
store = $.CNContactStore
store.unifiedContactWithIdentifierKeysToFetchError(id, keysToFetch, null)
...
這種失敗,錯誤-2700:腳本錯誤。彈出窗口說:TypeError: store.unifiedContactWithIdentifierKeysToFetchError is not a function
編輯:一個更簡單的例子,該defaultContainerIdentifier
方法給出了一個undefined
輸出:
ObjC.import('Contacts')
store = $.CNContactStore
console.log(store)
/* [Class CNContactStore] */
console.log(store.defaultContainerIdentifier)
/* undefined */
當然!謝謝。 – wivku