【发布时间】:2016-05-18 18:04:04
【问题描述】:
在尝试按照 Apple 文档(和 tutorial-ized)创建启动助手时,我似乎遇到了将 Objective-C 代码移植到 Swift 中而导致的问题......在这种情况下是多余的。
import ServiceManagement
let launchDaemon: CFStringRef = "com.example.ApplicationLauncher"
if SMLoginItemSetEnabled(launchDaemon, true) // Error appears here
{
// ...
}
错误似乎始终是:
Type 'Boolean' does not conform to protocol 'BooleanType'
我已尝试在多个位置投射到 Bool,以防我只是处理 redundant, archaic primitive(由 Obj-C 或 Core Foundation 引入),但无济于事。
以防万一,我已尝试投射响应:
SMLoginItemSetEnabled(launchDaemon, true) as Bool
产生错误:
'Boolean' is not convertible to 'Bool'
...认真的吗?
【问题讨论】:
-
亲爱的 Chris,你能添加我的 Skype:contact@giauhuynh.com 并帮助我实现 SMLoginItemSetEnabled。我现在在线。非常感谢。
标签: objective-c xcode swift osx-yosemite