Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 08b78f0

Browse files
author
Adam Eberbach
committed
@optional requires check for respondsToSelector...
1 parent be3233a commit 08b78f0

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

iPhone Apps/rfduino/RfduinoManager.m

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ - (bool)isBluetoothLESupported
9898

9999
}
100100

101-
[delegate shouldDisplayAlertTitled:@"Bluetooth LE Support" messageBody:message];
101+
if ([delegate respondsToSelector:@selector(shouldDisplayAlertTitled:messageBody:)]) {
102+
[delegate shouldDisplayAlertTitled:@"Bluetooth LE Support" messageBody:message];
103+
}
102104

103105
return NO;
104106
}
@@ -184,7 +186,9 @@ - (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPe
184186
if (error.code) {
185187
cancelBlock = block;
186188

187-
[delegate shouldDisplayAlertTitled:@"Peripheral Disconnected with Error" messageBody:error.description];
189+
if ([delegate respondsToSelector:@selector(shouldDisplayAlertTitled:messageBody:)]) {
190+
[delegate shouldDisplayAlertTitled:@"Peripheral Disconnected with Error" messageBody:error.description];
191+
}
188192

189193
}
190194
else
@@ -265,7 +269,9 @@ - (void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(C
265269
{
266270
NSLog(@"didFailToConnectPeripheral");
267271

268-
[delegate shouldDisplayAlertTitled:@"Connect Failed" messageBody:error.description];
272+
if ([delegate respondsToSelector:@selector(shouldDisplayAlertTitled:messageBody:)]) {
273+
[delegate shouldDisplayAlertTitled:@"Connect Failed" messageBody:error.description];
274+
}
269275
}
270276

271277
- (void)centralManager:(CBCentralManager *)central didRetrieveConnectedPeripherals:(NSArray *)peripherals

0 commit comments

Comments
 (0)