diff options
author | Muller, Alexander (A.) <amulle19@ford.com> | 2017-03-03 10:00:16 -0800 |
---|---|---|
committer | Muller, Alexander (A.) <amulle19@ford.com> | 2017-03-03 10:00:16 -0800 |
commit | 49b9414984347aed02ab5b3cd398f73c576e4720 (patch) | |
tree | 4383612f76340eaf1b1f70f5c91b2cb8a18aa5bb | |
parent | 7f364b19038acc3bf6b8f3a9d111ecc4005ea6fd (diff) | |
download | sdl_ios-49b9414984347aed02ab5b3cd398f73c576e4720.tar.gz |
Added an additional method to compare both membership and kindof for notification and responses.
-rw-r--r-- | SmartDeviceLink/SDLLifecycleManager.m | 4 | ||||
-rw-r--r-- | SmartDeviceLink/SDLLockScreenManager.m | 2 | ||||
-rw-r--r-- | SmartDeviceLink/SDLPermissionManager.m | 4 | ||||
-rw-r--r-- | SmartDeviceLink/SDLRPCNotificationNotification.h | 11 | ||||
-rw-r--r-- | SmartDeviceLink/SDLRPCNotificationNotification.m | 5 | ||||
-rw-r--r-- | SmartDeviceLink/SDLRPCResponseNotification.h | 10 | ||||
-rw-r--r-- | SmartDeviceLink/SDLRPCResponseNotification.m | 8 |
7 files changed, 35 insertions, 9 deletions
diff --git a/SmartDeviceLink/SDLLifecycleManager.m b/SmartDeviceLink/SDLLifecycleManager.m index 2416dd214..69802b0f4 100644 --- a/SmartDeviceLink/SDLLifecycleManager.m +++ b/SmartDeviceLink/SDLLifecycleManager.m @@ -434,7 +434,7 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready"; } - (void)hmiStatusDidChange:(SDLRPCNotificationNotification *)notification { - if (![notification isNotificationKindOfClass:[SDLOnHMIStatus class]]) { + if (![notification isNotificationMemberOfClass:[SDLOnHMIStatus class]]) { return; } @@ -452,7 +452,7 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready"; } - (void)remoteHardwareDidUnregister:(SDLRPCNotificationNotification *)notification { - if (![notification isNotificationKindOfClass:[SDLOnAppInterfaceUnregistered class]]) { + if (![notification isNotificationMemberOfClass:[SDLOnAppInterfaceUnregistered class]]) { return; } diff --git a/SmartDeviceLink/SDLLockScreenManager.m b/SmartDeviceLink/SDLLockScreenManager.m index e627d83e0..e93848eb9 100644 --- a/SmartDeviceLink/SDLLockScreenManager.m +++ b/SmartDeviceLink/SDLLockScreenManager.m @@ -91,7 +91,7 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - Notification Selectors - (void)sdl_lockScreenStatusDidChange:(SDLRPCNotificationNotification *)notification { - if (![notification isNotificationKindOfClass:[SDLOnLockScreenStatus class]]) { + if (![notification isNotificationMemberOfClass:[SDLOnLockScreenStatus class]]) { return; } diff --git a/SmartDeviceLink/SDLPermissionManager.m b/SmartDeviceLink/SDLPermissionManager.m index 3ed9ecfc3..b37ca5b5b 100644 --- a/SmartDeviceLink/SDLPermissionManager.m +++ b/SmartDeviceLink/SDLPermissionManager.m @@ -175,7 +175,7 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - SDL Notification Observers - (void)sdl_permissionsDidChange:(SDLRPCNotificationNotification *)notification { - if (![notification isNotificationKindOfClass:[SDLOnPermissionsChange class]]) { + if (![notification isNotificationMemberOfClass:[SDLOnPermissionsChange class]]) { return; } @@ -218,7 +218,7 @@ NS_ASSUME_NONNULL_BEGIN } - (void)sdl_hmiLevelDidChange:(SDLRPCNotificationNotification *)notification { - if (![notification isNotificationKindOfClass:[SDLOnHMIStatus class]]) { + if (![notification isNotificationMemberOfClass:[SDLOnHMIStatus class]]) { return; } diff --git a/SmartDeviceLink/SDLRPCNotificationNotification.h b/SmartDeviceLink/SDLRPCNotificationNotification.h index 4f163b0ac..a0f29ab5b 100644 --- a/SmartDeviceLink/SDLRPCNotificationNotification.h +++ b/SmartDeviceLink/SDLRPCNotificationNotification.h @@ -20,13 +20,20 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithName:(NSString *)name object:(nullable id)object rpcNotification:(__kindof SDLRPCNotification *)notification; /** - * - * Returns whether or not the containing notification is a kind of class. + * Returns whether or not the containing notification is equal to a class, not including subclasses. * * @param aClass the class your are questioning */ +- (BOOL)isNotificationMemberOfClass:(Class)aClass; + +/** + * Returns whether or not the containing notification is a kind of class, including subclasses. + * + * @param aClass the class you are questioning + */ - (BOOL)isNotificationKindOfClass:(Class)aClass; + @end NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink/SDLRPCNotificationNotification.m b/SmartDeviceLink/SDLRPCNotificationNotification.m index 9b281d5b2..78645c695 100644 --- a/SmartDeviceLink/SDLRPCNotificationNotification.m +++ b/SmartDeviceLink/SDLRPCNotificationNotification.m @@ -31,6 +31,11 @@ NS_ASSUME_NONNULL_BEGIN return _userInfo[SDLNotificationUserInfoObject]; } +- (BOOL)isNotificationMemberOfClass:(Class)aClass { + NSAssert([self.notification isMemberOfClass:aClass], @"A notification was sent with an unanticipated object"); + return [self.notification isMemberOfClass:aClass]; +} + - (BOOL)isNotificationKindOfClass:(Class)aClass { NSAssert([self.notification isKindOfClass:aClass], @"A notification was sent with an unanticipated object"); return [self.notification isKindOfClass:aClass]; diff --git a/SmartDeviceLink/SDLRPCResponseNotification.h b/SmartDeviceLink/SDLRPCResponseNotification.h index 161dbd2ba..3dcdb487c 100644 --- a/SmartDeviceLink/SDLRPCResponseNotification.h +++ b/SmartDeviceLink/SDLRPCResponseNotification.h @@ -20,11 +20,17 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithName:(NSString *)name object:(nullable id)object rpcResponse:(__kindof SDLRPCResponse *)response; /** - * - * Returns whether or not the containing response is a kind of class. + * Returns whether or not the containing response is equal to a class, not including subclasses. * * @param aClass the class your are questioning */ +- (BOOL)isResponseMemberOfClass:(Class)aClass; + +/** + * Returns whether or not the containing response is a kind of class, including subclasses. + * + * @param aClass the class you are questioning + */ - (BOOL)isResponseKindOfClass:(Class)aClass; @end diff --git a/SmartDeviceLink/SDLRPCResponseNotification.m b/SmartDeviceLink/SDLRPCResponseNotification.m index 09787b579..60e94cf8b 100644 --- a/SmartDeviceLink/SDLRPCResponseNotification.m +++ b/SmartDeviceLink/SDLRPCResponseNotification.m @@ -11,6 +11,7 @@ #import "SDLNotificationConstants.h" #import "SDLRPCResponse.h" +NS_ASSUME_NONNULL_BEGIN @implementation SDLRPCResponseNotification @@ -30,9 +31,16 @@ return _userInfo[SDLNotificationUserInfoObject]; } +- (BOOL)isResponseMemberOfClass:(Class)aClass { + NSAssert([self.response isMemberOfClass:aClass], @"A notification was sent with an unanticipated object"); + return [self.response isMemberOfClass:aClass]; +} + - (BOOL)isResponseKindOfClass:(Class)aClass { NSAssert([self.response isKindOfClass:aClass], @"A notification was sent with an unanticipated object"); return [self.response isKindOfClass:aClass]; } @end + +NS_ASSUME_NONNULL_END |