![](/img/trans.png)
[英]cannot convert value of type 'Range<Int32>' to expected argument type 'Range<_>'
[英]Cannot convert value of type 'Int' to expected argument type 'UnsafeMutablePointer<Int32>!'
通過使用此答案,我在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")
}
如何解決呢?
嘗試這樣的事情:
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")
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.