我用Swift编写了99%的文章,不明白为什么这个线程崩溃了。我无法复制它,但有时会发生。
该库为:LTSupportAutomotive https://github.com/mickeyl/LTSupportAutomotive
错误:(从HockeyApp Crash Reporter中获取) 在当前参数寄存器委托
中找到的选择器名称异常类型:SIGSEGV
异常代码:SEGV_ACCERR位于0xac7c95df0
mapboxgl.accessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
class Application extends React.Component {
componentDidMount() {
const map = new mapboxgl.Map({
container: 'map', // container id
style: 'mapbox://styles/mapbox/light-v9', // stylesheet location
center: [13.392, 52.523], // starting position [lng, lat]
zoom: 9 // starting zoom
});
map.addControl(new mapboxgl.NavigationControl());
map.resize(); // tried with this to see if it would help
}
render() {
return (
<div className="row no-gutters">
<div className="col-9">
<div className="map-wrapper">
<div ref={el => this.mapContainer = el} id="map"/>
</div>
</div>
<div className="col-3">
2 of 2
</div>
</div>
)
}
}
ReactDOM.render(<Application/>, document.getElementById('app'));
崩溃代码
Thread 6 Crashed:
0 libobjc.A.dylib 0x00000001fe175430 objc_retain + 16
1 LTSupportAutomotive 0x00000001065816f8 -[LTBTLEReadCharacteristicStream characteristicDidUpdateValue] (LTBTLEReadCharacteristicStream.m:43)
2 LTSupportAutomotive 0x0000000106582ac8 -[LTBTLESerialTransporter peripheral:didUpdateValueForCharacteristic:error:] (LTBTLESerialTransporter.m:299)
3 CoreBluetooth 0x0000000204b42cc0 -[CBPeripheral handleAttributeEvent:args:attributeSelector:delegateSelector:delegateFlag:] + 236
4 CoreBluetooth 0x0000000204b42e20 -[CBPeripheral handleCharacteristicEvent:characteristicSelector:delegateSelector:delegateFlag:] + 128
5 CoreBluetooth 0x0000000204b3e4d0 -[CBPeripheral handleMsg:args:] + 352
6 CoreBluetooth 0x0000000204b38bdc -[CBCentralManager handleMsg:args:] + 200
7 CoreBluetooth 0x0000000204b47750 __30-[CBXpcConnection _handleMsg:]_block_invoke + 56
8 libdispatch.dylib 0x00000001fe9c56c8 _dispatch_call_block_and_release + 20
9 libdispatch.dylib 0x00000001fe9c6484 _dispatch_client_callout + 12
10 libdispatch.dylib 0x00000001fe96dbd0 _dispatch_lane_serial_drain$VARIANT$mp + 588
11 libdispatch.dylib 0x00000001fe96e74c _dispatch_lane_invoke$VARIANT$mp + 480
12 libdispatch.dylib 0x00000001fe96da9c _dispatch_lane_serial_drain$VARIANT$mp + 280
13 libdispatch.dylib 0x00000001fe96e718 _dispatch_lane_invoke$VARIANT$mp + 428
14 libdispatch.dylib 0x00000001fe976eb8 _dispatch_workloop_worker_thread + 596
15 libsystem_pthread.dylib 0x00000001feba90dc _pthread_wqthread + 308
16 libsystem_pthread.dylib 0x00000001febabcec start_wqthread + 0
从这里开始:
-(void)characteristicDidUpdateValue
{
NSData* value = _characteristic.value;
[_buffer appendData:value];
[self.delegate stream:self handleEvent:NSStreamEventHasBytesAvailable]; <--- here it is crashing
}
有人可以帮助我使用Objective-C以避免崩溃吗?
谢谢
答案 0 :(得分:0)
委托的声明是unsafe_unretained,而不是弱声明。