Error _BSMachError: (os/kern) invalid capability (20) after receiving remote notification on CloudKit record addition

眉间皱痕 提交于 2019-12-17 23:32:16

问题


When I receive a remote notification on a record addition (didReceiveRemoteNotification called), I get the following error message:

_BSMachError: (os/kern) invalid capability (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?


回答1:


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.

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!




回答2:


For Swift 5, I ended up with:

func alertAction() {
  DispatchQueue.main.async {
     //perform code
  }
}



回答3:


Thank you very much, I had the same issue on swift

So I've resolved it by putting code in main thread

func alertAction() {
  dispatch_async(dispatch_get_main_queue()) {
    //perform code
  }
}



回答4:


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



来源:https://stackoverflow.com/questions/31720133/error-bsmacherror-os-kern-invalid-capability-20-after-receiving-remote-not

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!