summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicoleYarroch <nicole@livio.io>2020-07-02 13:27:17 -0400
committerNicoleYarroch <nicole@livio.io>2020-07-02 13:27:17 -0400
commit0c7463abcb9ce82d3c118480e5a02c249673c3d7 (patch)
tree0b7c5c46bbc397e11a723a13db28061008cc718a
parent798432e630fcfe004669b06fa83f99359a8d4935 (diff)
downloadsdl_ios-0c7463abcb9ce82d3c118480e5a02c249673c3d7.tar.gz
Added error log
Signed-off-by: NicoleYarroch <nicole@livio.io>
-rw-r--r--SmartDeviceLink_Example/SubscribeButtonManager.m7
-rw-r--r--SmartDeviceLink_Example/SubscribeButtonManager.swift8
2 files changed, 10 insertions, 5 deletions
diff --git a/SmartDeviceLink_Example/SubscribeButtonManager.m b/SmartDeviceLink_Example/SubscribeButtonManager.m
index 51dcf9a1c..4cb0ba0a9 100644
--- a/SmartDeviceLink_Example/SubscribeButtonManager.m
+++ b/SmartDeviceLink_Example/SubscribeButtonManager.m
@@ -42,14 +42,17 @@ NS_ASSUME_NONNULL_BEGIN
__weak typeof(self) weakSelf = self;
[self.sdlManager.screenManager subscribeButton:buttonName withUpdateHandler:^(SDLOnButtonPress * _Nullable buttonPress, SDLOnButtonEvent * _Nullable buttonEvent, NSError * _Nullable error) {
__strong typeof(weakSelf) strongSelf = weakSelf;
- if (error != nil || buttonPress == nil) {
+ if (error != nil) {
+ SDLLogE(@"There was an error subscribing to the preset button: %@" error.localizedDescription);
return;
}
+ if (buttonPress == nil) { return; }
+
NSString *alertMessage;
NSString *buttonName = buttonPress.buttonName;
if ([buttonPress.buttonPressMode isEqualToEnum:SDLButtonPressModeShort]) {
- alertMessage = [NSString stringWithFormat:@"%@ pressed", buttonName];
+ alertMessage = [NSString stringWithFormat:@"%@ short pressed", buttonName];
} else {
alertMessage = [NSString stringWithFormat:@"%@ long pressed", buttonName];
}
diff --git a/SmartDeviceLink_Example/SubscribeButtonManager.swift b/SmartDeviceLink_Example/SubscribeButtonManager.swift
index 25156b01c..d7aa1a3bd 100644
--- a/SmartDeviceLink_Example/SubscribeButtonManager.swift
+++ b/SmartDeviceLink_Example/SubscribeButtonManager.swift
@@ -27,16 +27,18 @@ class SubscribeButtonManager {
presetButtons.forEach { buttonName in
_ = sdlManager.screenManager.subscribeButton(buttonName) { [weak self] (press, event, error) in
- guard error == nil, let buttonPress = press else {
- SDLLog.e("Error subscribing to the \(buttonName.rawValue.rawValue) button")
+ guard error == nil else {
+ SDLLog.e("There was an error subscribing to the preset button: \(error!.localizedDescription)")
return
}
+ guard let buttonPress = press else { return }
+
let alert: SDLAlert
let buttonName = buttonPress.buttonName.rawValue.rawValue
switch buttonPress.buttonPressMode {
case .short:
- alert = AlertManager.alertWithMessageAndCloseButton("\(buttonName) pressed")
+ alert = AlertManager.alertWithMessageAndCloseButton("\(buttonName) short pressed")
case .long:
alert = AlertManager.alertWithMessageAndCloseButton("\(buttonName) long pressed")
default: fatalError()