Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 错误消息'_BSMachError:(os/kern)无效功能(20)和#x27;_Ios_Objective C_Xcode7 - Fatal编程技术网

Ios 错误消息'_BSMachError:(os/kern)无效功能(20)和#x27;

Ios 错误消息'_BSMachError:(os/kern)无效功能(20)和#x27;,ios,objective-c,xcode7,Ios,Objective C,Xcode7,请注意,此错误消息的级别非常低,因此在不同的场景中会出现不同的原因。如果你有一个在下面一个答案中没有提到的场景,请考虑添加你的情况,所以这可能是引发错误信息的各种情况的一个中心答案。 编辑2015年11月10日另请注意,我将自己的答案标记为答案,但那是在其他人发布之前。我想没有一个应该被标记为答案,因为正如我们现在看到的。。。这个错误并不是只有一个答案,因为它的级别太低了 我在跑步 iOS 9.0模拟器 XCode 7.0 昨天一切正常 今天,在做了大量与旋转相关的工作之后,当我在模拟器中运

请注意,此错误消息的级别非常低,因此在不同的场景中会出现不同的原因。如果你有一个在下面一个答案中没有提到的场景,请考虑添加你的情况,所以这可能是引发错误信息的各种情况的一个中心答案。 编辑2015年11月10日另请注意,我将自己的答案标记为答案,但那是在其他人发布之前。我想没有一个应该被标记为答案,因为正如我们现在看到的。。。这个错误并不是只有一个答案,因为它的级别太低了

我在跑步

  • iOS 9.0模拟器
  • XCode 7.0
昨天一切正常

今天,在做了大量与旋转相关的工作之后,当我在模拟器中运行应用程序并旋转它时,我的控制台输出中开始出现这个错误

_BSMachError:(操作系统/内核)无效功能(20)

_BSMachError:(os/kern)名称无效(15)

-我已经清除了生成文件夹, -我已经清理了派生数据文件夹, -我已经重置了模拟器

我和他一起工作

  • UIViewController视图将布局子视图
  • UIViewController视图将转换为大小:…
我还在IB中的属性检查器上检查各种“绘图”设置

我还在UIView上创建了一个实用程序类别,在那里我创建了一系列方法来创建
CGRect
,并帮助我为视图分配帧


好的,我还没有把它完全固定住,但这会让你99%的成功。 我使用的是来自ESRI的第三方贴图控件,它与Attributes Inspector中的这些图形设置不一样。我没有单独尝试每个设置以查看它是哪种设置,但是当我关闭所有设置(在红色框中)时,一切都很顺利,我不再在控制台中收到上面的错误消息。如果我有时间确定精确的设置或设置组合,我会更新答案


在提供新数据时,我得到了以下信息:

> _BSMachError: (os/kern) invalid capability (20)
> _BSMachError: (os/kern) invalid name (15)
使用按钮提供新数据时出错。
NSTimer
用于在从
performsguewithidentifier
操作返回时刷新和更新数据。计时器被激活,然后在返回时间使用后立即失效。移除计时器后,
MSMachError
停止,并且-
(void)视图将出现:(BOOL)动画
(void)视图显示:(BOOL)动画
用于执行相同的功能。此错误始于升级到Xcode 7

基于:

info.plist
中的“本地化本地开发区域”更改为美国,而不是
en


更新:然后您可以恢复这些更改。

我收到了相同的错误消息,因为我
assign
a
object
属性,如
@property(assign,nonatomic)NSNumber*aVariable,通过更改为
strong

进行修复。在通过
UIAlertController
操作深入链接到iOS 9上的设置应用程序时,我也遇到了
\BSMachError
控制台错误。
dispatch\u async
解决了我的问题:

[aAlertVC addAction:[UIAlertAction actionWithTitle:@"Settings" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
    dispatch_async(dispatch_get_main_queue(), ^{
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
    });
}]];

在我的例子中,它是小告密者,它自动阻止URL。

我可以为自己重现错误: 如果对我实际上已经关闭的视图(popViewControllerAnimated)中的一个视图进行更改,我将收到错误

我有一个UINavigationButton操作,它生成一个异步任务(POSTRequest)。 在执行此请求之前,我将该按钮的customView设置为进度指示器。 从异步调用返回时,我将调度到主线程并重置该按钮的customView。 之后,我将关闭视图(popViewControllerAnimated)

这是未出现错误的正确代码:

/* right way, working without BSMachError */
@IBAction func sendRequest(sender: UIBarButtonItem) {
    /* setting the progress indicator as customView of the self.saveButton */
    self.showActivityIndicatory(self.saveButton)
    /* asynchronous REST call */
    UserDataManager.sharedInstance.requestFeedback(request, onCompletion: { error in
        dispatch_async(dispatch_get_main_queue(),{
        /* resetting the saveButton again to default by setting customView to nil */
        self.saveButton.customView = nil
        /* closing the view */
        self.navigationController!.popViewControllerAnimated(true)
      })
    })
}
导致错误的原因是切换行:关闭视图,然后将customView设置为零:

/* WRONG way, causing BSMachError */
@IBAction func sendRequest(sender: UIBarButtonItem) {
    /* setting the progress indicator as customView of the self.saveButton */
    self.showActivityIndicatory(self.saveButton)
    /* asynchronous REST call */
    UserDataManager.sharedInstance.requestFeedback(request, onCompletion: { error in
        dispatch_async(dispatch_get_main_queue(),{
        /* closing the view */
        self.navigationController!.popViewControllerAnimated(true)
        /* resetting the saveButton again to default by setting customView to nil */
        self.saveButton.customView = nil
      })
    })
}

在后台线程上运行的NSO操作中,我也遇到了同样的问题,我仍然会遇到这个错误,因为当另一个UI事务试图发生时,UIAlertController仍在删除自身。将我的代码修改为此解决了这个问题

defer { 
    dispatch_async( dispatch_get_main_queue(),{
        completion()
    }) 
}

很多人不知道延迟-它让当前范围完成,然后再运行。有点整洁

我通过将
Localization native development region
键的值从项目的
info.plist
中的默认值
en
更改为
United Kingdom
[或任何特定区域],解决了这个问题

  • 选择项目导航器
  • 找到ProjectNameTests文件夹中的
    info.plist
    文件
  • 本地化本地开发区域键的值更改为任何特定区域,例如英国

  • 不管它值多少钱,似乎很多情况下都会出现这种错误。在我的例子中,当用户拒绝一个数据输入表单并且表单中有数据时,我发布了一个警报。在展开视图控制器之前,我可以通过编程方式从所有适用字段重新指定第一响应者来消除错误。

    当我按下
    主页
    按钮时,我看到了这一点,同时显示了
    UIAlertController
    ,当我重新启动应用程序时,该按钮被取消。我在
    appDelegate
    中添加了代码以关闭
    UIAlertController

    func applicationWillResignActive(application: UIApplication) {
      window?.rootViewController?.dismissViewControllerAnimated(false, completion: nil)
    }
    

    错误信息消失。

    一些开发人员在从“美国”改为“欧洲”(或)其他地区后没有收到错误,原因是“属性列表”和“源代码”vie之间存在差异
    //Create a alertView add UIActivityIndicatorView to it and present it in ViewController
    
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
    //Call method 1 todo background process like getting data
    
    dispatch_sync(dispatch_get_main_queue(), ^{
        //Call method 2 to update the UI
        [alert dismissViewControllerAnimated:YES completion:^(void){
            //My mistake was: I was calling method 2 over here to update the UI
            return;
        }];
    });
    });
    
    [myPopoverView dismissViewControllerAnimated:YES completion:^{ //GUI-Stuff}];
    
    _BSMachError: (os/kern) invalid capability (20)
    _BSMachError: (os/kern) invalid name (15)
    
    alert.addAction(UIAlertAction(title: actionTitle, style: .Default) {
        UIApplication.shared.openURL(url)
     }
    
    alert.addAction(UIAlertAction(title: actionTitle, style: .Default) {
        OperationQueue.main.addOperation {UIApplication.shared.openURL(url)}
     }
    
    NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(self.keyboardWillHideOrShow(_:)), name:UIKeyboardWillShowNotification, object: nil)
    
    NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(self.keyboardWillHideOrShow(_:)), name:UIKeyboardWillHideNotification, object: nil)
    
    NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(MyClass.keyboardWillHideOrShow(_:)), name:UIKeyboardWillShowNotification, object: nil)
    
    NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(MyClass.keyboardWillHideOrShow(_:)), name:UIKeyboardWillHideNotification, object: nil)
    
    var promptsArr =  StartRegAlerts() //Instance of the class
    
    func textFieldDidBeginEditing(textField: UITextField) {     
        switch textField.tag {
                case 0:
                    alert(promptsArr.prompts["Name"]!)
                case 1:
                    alert(promptsArr.prompts["CellPhone"]!)
                case 4:
                    alert2(promptsArr.prompts["NUMBERCORRECT"]!)
                    //alert(promptsArr.prompts["Wait4Pin"]!)
    
                default: break
                }
    It only occurred for case 0 but not the other cases:
    As a work around for now I commented out case 0 and that stopped the error.
    I then changed  calling promptsArr.prompts by:
    
     override func viewDidAppear(animated: Bool) {
                 prompt = promptsArr.prompts //
          }
    
    _BSMachError: (os/kern) invalid capability (20)
    _BSMachError: (os/kern) invalid name (15)
    
    override public var traitCollection: UITraitCollection {
        if UIDevice.currentDevice().userInterfaceIdiom == .Pad && UIDevice.currentDevice().orientation.isPortrait.boolValue {
            return UITraitCollection(traitsFromCollections:[UITraitCollection(horizontalSizeClass: .Compact), UITraitCollection(verticalSizeClass: .Regular)])
        }
        return super.traitCollection
    }