ios 错误 _BSMachError: (os/kern) 在收到有关 CloudKit 记录添加的远程通知后的无效能力 (20)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31720133/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error _BSMachError: (os/kern) invalid capability (20) after receiving remote notification on CloudKit record addition
提问by vomako
When I receive a remote notification on a record addition (didReceiveRemoteNotification called), I get the following error message:
当我收到关于记录添加的远程通知(didReceiveRemoteNotification 调用)时,我收到以下错误消息:
_BSMachError: (os/kern) invalid capability (20)
_BSMachError: (os/kern) 无效能力 (20)
I've already tried to find out more about this in forums and via Google but I could not find any helpful advice that applies to my situation.
我已经尝试在论坛和谷歌中找到更多关于此的信息,但我找不到任何适用于我的情况的有用建议。
What does the error message mean? What can I do about it?
错误信息是什么意思?我该怎么办?
回答by davidey
I just experienced this error. I was in a UIAlert
Action block; when the block exited the error occurred (BTW the parent UIAlertViewController
was created in a dispatch_async block
so was I guess off main thread.
我刚刚经历了这个错误。我在一个UIAlert
动作块中;当块退出时发生错误(顺便说一句,父级UIAlertViewController
是在dispatch_async block
主线程中创建的,所以我猜是主线程。
Anyway, I wrapped the action code itself in
无论如何,我将操作代码本身包装在
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self handleActionForElement:thisType];
});
and error went away. Your mileage may vary!
错误消失了。你的旅费可能会改变!
回答by cwgso
For Swift 5, I ended up with:
对于 Swift 5,我最终得到:
func alertAction() {
DispatchQueue.main.async {
//perform code
}
}
回答by Svitlana
Thank you very much, I had the same issue on swift
非常感谢,我在swift上遇到了同样的问题
So I've resolved it by putting code in main thread
所以我通过在主线程中放置代码来解决它
func alertAction() {
dispatch_async(dispatch_get_main_queue()) {
//perform code
}
}
回答by Sunil
Had same issue. I was trying to present a custom view on top of a presented view controller of third party framework.
有同样的问题。我试图在第三方框架的呈现视图控制器之上呈现自定义视图。
Resolved by moving the presentation logic to my view controller
通过将表示逻辑移动到我的视图控制器来解决