我开发了一个适用于“ ant + connectors (footpod and heartrate)
”的 iOS iPad 应用程序。
为了与这两个连接器连接,我使用了 Wahoo api ( WFConnector.framework
)。在我在 iPad Retina 设备上进行测试之前,它运行良好。
它在 iPad 3 视网膜上崩溃的方法
- (NSArray*)getSensorConnections:(WFSensorType_t)sensorType;
当我尝试将 garmin footpod 与我的应用程序连接时。
它在 iPad 2(ios7 和 ios8)上运行良好,我不明白为什么它只在 iPad 3 视网膜上崩溃。我认为这可能是因为 iPad 3 中的 64 位架构。但它与崩溃有什么关系。
我使用以下代码更新传感器:
- (void)updateSensorStatusNew
{
@try {
@autoreleasepool {
// configure the status fields for the heartrate sensor.
NSArray* connections = [hardwareConnector getSensorConnections:WF_SENSORTYPE_HEARTRATE]; /////////**************************** I GET CRASH ON THIS LINE
ALog(@"here in %@",[self class]);
WFSensorConnection* sensor = ([connections count]>0) ? (WFSensorConnection*)[connections objectAtIndex:0] : nil;
if ( sensor )
{
//WFHeartrateData* hrData = [(WFHeartrateConnection*)sensor getHeartrateData];
BOOL hrConnected = (sensor != nil && sensor.isConnected) ? TRUE : FALSE;
//USHORT devId = sensor.deviceNumber;
if ( hrConnected) {
//lbl2.text = @"HR 7 Connected";
}
else {
// lbl2.text = @"HR 8 Not Connected";
}
}
else
{
//lbl2.text = @"HR 9 Not Connected";
}
// configure the status fields for the Bike Speed and Cadence sensor.
connections = [hardwareConnector getSensorConnections:WF_SENSORTYPE_FOOTPOD];
ALog(@"%@,%lu",connections,(unsigned long)connections.count);
ALog(@"here in %@",[self class]);
sensor = ([connections count]>0) ? (WFSensorConnection*)[connections objectAtIndex:0] : nil;
ALog(@"here in %@",[self class]);
if ( sensor )
{
//WFFootpodData* fpData = [(WFFootpodConnection*)sensor getFootpodData];
ALog(@"here in 308 %@",[self class]);
BOOL fpConnected = (sensor != nil && sensor.isConnected) ? TRUE : FALSE;
//USHORT devId = sensor.deviceNumber;
if ( fpConnected) {
// lbl3.text = @"FP 10 Connected";
}
else {
//lbl3.text = @"FP 11 Not Connected";
}
}
else
{
//lbl3.text = @"FP 12 Not Connected";
/*
fpConnectedLabel.text = @"No";
fpDeviceIdLabel.text = @"n/a";
fpSignalLabel.text = @"n/a";*/
}
}
ALog(@"here in 327 %@",[self class]);
}
@catch (NSException *exception) {
NSLog(@"Exception:%@",exception);
}
@finally {
//Display Alternative
}
}
我正在使用该功能的崩溃日志是
Nov 14 11:26:52 VirtualRunner-V3[6642] <Warning>: App crashing with exception: *** -[__NSArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]
Nov 14 11:26:52 VirtualRunner-V3[6642] <Error>: *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
*** First throw call stack:
(0x2ffeaf83 0x3ab8dccf 0x2ff21a39 0x8448b 0x839cf 0x2ffad1a1 0x2ff214ef 0x3090ca3d 0x3091131b 0x27c3f 0x2d00d1 0x309d5b05 0x2ffb6167 0x2ffb5d7f 0x2ffb411b 0x2ff1eebf 0x2ff1eca3 0x34e45663 0x3286b14d 0x172e29 0x22108)
Nov 14 11:26:52 VirtualRunner-V3[6642] <Warning>: We received a signal: 6
我也将我的更新WFConnector.framework
到了最新版本。
如何解决这个问题?
谢谢。