-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #494 from smartdevicelink/feature/struct_property_…
…rewrite Feature/struct property rewrite
- Loading branch information
Showing
172 changed files
with
1,543 additions
and
5,681 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// NSMutableDictionary+Store.h | ||
// SmartDeviceLink-iOS | ||
// | ||
// Created by Muller, Alexander (A.) on 11/7/16. | ||
// Copyright © 2016 smartdevicelink. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "SDLMacros.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
typedef NSString* SDLName SDL_SWIFT_ENUM; | ||
typedef NSString* SDLEnum SDL_SWIFT_ENUM; | ||
|
||
@interface NSMutableDictionary (Store) | ||
|
||
- (void)sdl_setObject:(NSObject *)object forName:(SDLName)name; | ||
- (nullable id)sdl_objectForName:(SDLName)name; | ||
- (nullable id)sdl_objectForName:(SDLName)name ofClass:(Class)classType; | ||
- (NSMutableArray *)sdl_objectsForName:(SDLName)name ofClass:(Class)classType; | ||
- (NSMutableArray<SDLEnum> *)sdl_enumsForName:(SDLName)name; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// | ||
// NSMutableDictionary+Store.m | ||
// SmartDeviceLink-iOS | ||
// | ||
// Created by Muller, Alexander (A.) on 11/7/16. | ||
// Copyright © 2016 smartdevicelink. All rights reserved. | ||
// | ||
|
||
#import "NSMutableDictionary+Store.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@implementation NSMutableDictionary (Store) | ||
|
||
- (void)sdl_setObject:(NSObject *)object forName:(SDLName)name { | ||
if (object != nil) { | ||
self[name] = object; | ||
} else { | ||
[self removeObjectForKey:name]; | ||
} | ||
} | ||
|
||
- (nullable id)sdl_objectForName:(SDLName)name { | ||
return self[name]; | ||
} | ||
|
||
- (nullable id)sdl_objectForName:(SDLName)name ofClass:(Class)classType { | ||
NSObject *obj = [self sdl_objectForName:name]; | ||
if (obj == nil || [obj isKindOfClass:classType.class]) { | ||
return obj; | ||
} else { | ||
return [[classType alloc] initWithDictionary:(NSDictionary *)obj]; | ||
} | ||
} | ||
|
||
- (NSMutableArray *)sdl_objectsForName:(SDLName)name ofClass:(Class)classType { | ||
NSMutableArray *array = [self sdl_objectForName:name]; | ||
if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:classType.class]) { | ||
return array; | ||
} else { | ||
NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; | ||
for (NSDictionary<NSString *, id> *dict in array) { | ||
[newList addObject:[[classType alloc] initWithDictionary:dict]]; | ||
} | ||
return newList; | ||
} | ||
} | ||
|
||
- (NSMutableArray<SDLEnum> *)sdl_enumsForName:(SDLName)name { | ||
NSMutableArray<SDLEnum> *array = [self sdl_objectForName:name]; | ||
if ([array count] < 1) { | ||
return array; | ||
} else { | ||
NSMutableArray<SDLEnum> *newList = [NSMutableArray arrayWithCapacity:[array count]]; | ||
for (SDLEnum enumString in array) { | ||
[newList addObject:enumString]; | ||
} | ||
return newList; | ||
} | ||
} | ||
|
||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.