使用此Answer我在swift 4.1中收到此错误,即Cannot convert value of type 'Int' to expected argument type 'UnsafeMutablePointer<Int32>!'
var notify_token: Int
notify_register_dispatch("com.apple.springboard.lockstate", notify_token, DispatchQueue.main, { (_ token: Int) -> Void in
var state: UInt64 = UINT64_MAX
notify_get_state(token, state)
if state == 0 {
print("unlock device")
}
else {
print("lock device")
}
如何解决这个问题?
答案 0 :(得分:1)
尝试这样的事情:
var notify_token: Int32
notify_register_dispatch("com.apple.springboard.lockstate", ¬ify_token, DispatchQueue.main, { (_ token: Int) -> Void in
var state: UInt64 = UINT64_MAX
notify_get_state(token, state)
if state == 0 {
print("unlock device")
}
else {
print("lock device")
}
}