将框架特定常量加载到 MacRuby

发布于 2024-12-23 03:45:58 字数 423 浏览 3 评论 0原文

我正在编写一个小型 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

生活了然无味 2024-12-30 03:45:58

在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文