【发布时间】:2016-11-06 23:21:33
【问题描述】:
我一直试图捕捉CancelPeripheralConnection 抛出的NSException,但它一直说它需要从system.exception 派生。
try
{
if (device.NativeDevice as CBPeripheral != null)
{
this.central.CancelPeripheralConnection(device.NativeDevice as CBPeripheral);
}
else
{
System.Diagnostics.Debug.WriteLine("Null CBPeripheral Disconnect");
}
}
catch (Foundation.NSErrorException)
{
//works
System.Diagnostics.Debug.WriteLine("Caught ns Error exception");
}
catch (Foundation.NSException)
{
//doesn't work
System.Diagnostics.Debug.WriteLine("Caught ns exception");
}
当它崩溃时,我的输出窗口中不断出现以下内容
2016-07-05 08:41:16.579 BadgeManageriOS[1066:685789] *** Assertion failure in -[CBCentralManager cancelPeripheralConnection:force:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/CoreBluetooth/CoreBluetooth-327.3/CBCentralManager.m:332
我的问题是我应该如何捕捉NSException,因为我似乎找不到任何文档可以让人们在它抛出它的地方捕捉它。
【问题讨论】:
标签: c# ios xamarin core-bluetooth