diff options
Diffstat (limited to 'SmartDeviceLink/SDLRPCStruct.m')
-rw-r--r-- | SmartDeviceLink/SDLRPCStruct.m | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/SmartDeviceLink/SDLRPCStruct.m b/SmartDeviceLink/SDLRPCStruct.m index cd0f4d481..0e83c51aa 100644 --- a/SmartDeviceLink/SDLRPCStruct.m +++ b/SmartDeviceLink/SDLRPCStruct.m @@ -12,6 +12,9 @@ - (id)initWithDictionary:(NSMutableDictionary *)dict { if (self = [super init]) { if (dict != nil) { + if (![self sdl_isDictionaryValid:dict]) { + return nil; + } store = dict; } else { store = [[NSMutableDictionary alloc] init]; @@ -85,4 +88,21 @@ store = nil; } +- (BOOL)sdl_isDictionaryValid:(NSMutableDictionary*)dict { + BOOL isValid = YES; + for (NSString *key in dict.allKeys) { + id value = dict[key]; + if ([value isKindOfClass:[NSDictionary class]]) { + isValid = [self sdl_isDictionaryValid:value]; + } else if ([value isKindOfClass:[NSNull class]]) { + isValid = NO; + } + + if (!isValid) { + break; + } + } + return isValid; +} + @end |