将框架特定常量加载到 MacRuby
我正在编写一个小型 MacRuby 脚本来从搜索查询中获取一些 ABRecord,但我不确定如何访问在 AddressBook 框架的特定头文件中声明的枚举。
我有这个脚本,我正在尝试拥有 kABFirstNameProperty & kABEqual 作为常量引入环境中。但运行脚本时找不到这两个常量。
framework "Cocoa"
framework "AddressBook"
globalAddressBook = ABAddressBook.sharedAddressBook
criteriaElement = ABPerson.searchElementForProperty(kABFirstNameProperty, label:nil, key:nil, value:"Callum", comparison:kABEqual)
I am writing a small MacRuby script to grab some ABRecords from a search query, but I am unsure how to gain access to enums declared in a specific header file for the AddressBook framework.
I have this script and I am trying to have kABFirstNameProperty & kABEqual brought into the environment as constants. But when running the script the two constants cannot be found.
framework "Cocoa"
framework "AddressBook"
globalAddressBook = ABAddressBook.sharedAddressBook
criteriaElement = ABPerson.searchElementForProperty(kABFirstNameProperty, label:nil, key:nil, value:"Callum", comparison:kABEqual)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 MacRuby 中(就像 Ruby 一样),常量按照惯例以大写字母开头,因此即使 AddressBook 将其定义为 kABFirstNameProperty,您也需要将其拼写为 KABFirstNameProperty。当然,您的示例中的 KABEqual 常量也是如此。
In MacRuby (just as with Ruby) constants start with a capital letter by convention, so even though AddressBook defines this as kABFirstNameProperty, you need to spell it as KABFirstNameProperty. The same goes for the KABEqual constant in your example, of course.