当我尝试访问数组时,最终出现此异常,但是当我在其中添加断点并尝试在调试器日志中打印时,数组似乎具有值并且似乎没有错误

oldDevices.forEach { (oldDevice) in
                if(self.averageRssis.count > 0){
                    if(self.averageRssis[oldDevice.bluetoothId] != nil)
                       {
                        self.averageRssis[oldDevice.bluetoothId] = nil
                        DispatchQueue.main.async {
                            self.bluetoothManager.remove(device:
                            oldDevice)
                        }
                    }
                }
            }



  *由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'-[NSTaggedPointerString count]:无法识别的选择器已发送到实例0x8000000000000000'
  *首先抛出调用堆栈:
  (0x1c19ca98c 0x1c0ba39f8 0x1c18e71c8 0x1c19d01d4 0x1c19d1e6c 0x1efc638a8 0x102ef9f44 0x102efa90c 0x102f00f40 0x1efd2f23c 0x102ef965c 0x102f21cf8 0x102eefaec 0x103004c78 0x103007ffc 0x10301a610 0x103015dc8 0x1030167ac 0x1c15ea1b4 0x1c15eccd4)
  libc ++ abi.dylib:以NSException类型的未捕获异常终止

最佳答案

您发布的代码段可能不是问题所在。我建议您阅读此(http://blog.manbolo.com/2012/01/23/xcode-tips-1-break-on-exceptions)并尝试隔离问题区域。祝好运!

10-07 12:38