Skip to content

Commit

Permalink
Merge pull request #494 from smartdevicelink/feature/struct_property_…
Browse files Browse the repository at this point in the history
…rewrite

Feature/struct property rewrite
  • Loading branch information
joeljfischer authored Jan 19, 2017
2 parents 3429c38 + 41bd47f commit 69638e1
Show file tree
Hide file tree
Showing 172 changed files with 1,543 additions and 5,681 deletions.
1 change: 1 addition & 0 deletions SmartDeviceLink-iOS.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ s.source_files = "SmartDeviceLink/*.{h,m}"
s.requires_arc = true
s.resource_bundles = { 'SmartDeviceLink' => ['SmartDeviceLink/Assets/**/*', 'SmartDeviceLink/iOS 7 Assets/*'] }
s.public_header_files = [
'SmartDeviceLink/NSMutableDictionary+Store.h',
'SmartDeviceLink/SmartDeviceLink.h',
'SmartDeviceLink/SDLJingle.h',
'SmartDeviceLink/SDLProxy.h',
Expand Down
8 changes: 8 additions & 0 deletions SmartDeviceLink-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,8 @@
5DFFB9151BD7C89700DB3F04 /* SDLConnectionManagerType.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DFFB9141BD7C89700DB3F04 /* SDLConnectionManagerType.h */; };
DA0C46AD1DCD35080001F2A8 /* SDLNames.m in Sources */ = {isa = PBXBuildFile; fileRef = DA0C46AC1DCD35080001F2A8 /* SDLNames.m */; };
DA0C46AF1DCD41E30001F2A8 /* SDLMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = DA0C46AE1DCD41E30001F2A8 /* SDLMacros.h */; settings = {ATTRIBUTES = (Public, ); }; };
DA318C1F1DD0F06C00C035AC /* NSMutableDictionary+Store.h in Headers */ = {isa = PBXBuildFile; fileRef = DA318C1D1DD0F06C00C035AC /* NSMutableDictionary+Store.h */; settings = {ATTRIBUTES = (Public, ); }; };
DA318C201DD0F06C00C035AC /* NSMutableDictionary+Store.m in Sources */ = {isa = PBXBuildFile; fileRef = DA318C1E1DD0F06C00C035AC /* NSMutableDictionary+Store.m */; };
DA4353DF1D271FD10099B8C4 /* CGPointUtilSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4353DE1D271FD10099B8C4 /* CGPointUtilSpec.m */; };
DA4353E31D2720A30099B8C4 /* SDLPinchGestureSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4353E21D2720A30099B8C4 /* SDLPinchGestureSpec.m */; };
DA4353E91D2721680099B8C4 /* DispatchTimerSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4353E61D2721680099B8C4 /* DispatchTimerSpec.m */; };
Expand Down Expand Up @@ -1891,6 +1893,8 @@
5DFFB9141BD7C89700DB3F04 /* SDLConnectionManagerType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLConnectionManagerType.h; sourceTree = "<group>"; };
DA0C46AC1DCD35080001F2A8 /* SDLNames.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLNames.m; sourceTree = "<group>"; };
DA0C46AE1DCD41E30001F2A8 /* SDLMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLMacros.h; sourceTree = "<group>"; };
DA318C1D1DD0F06C00C035AC /* NSMutableDictionary+Store.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMutableDictionary+Store.h"; sourceTree = "<group>"; };
DA318C1E1DD0F06C00C035AC /* NSMutableDictionary+Store.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSMutableDictionary+Store.m"; sourceTree = "<group>"; };
DA4353DE1D271FD10099B8C4 /* CGPointUtilSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CGPointUtilSpec.m; path = UtilitiesSpecs/Touches/CGPointUtilSpec.m; sourceTree = "<group>"; };
DA4353E21D2720A30099B8C4 /* SDLPinchGestureSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLPinchGestureSpec.m; path = UtilitiesSpecs/Touches/SDLPinchGestureSpec.m; sourceTree = "<group>"; };
DA4353E61D2721680099B8C4 /* DispatchTimerSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DispatchTimerSpec.m; path = UtilitiesSpecs/Touches/DispatchTimerSpec.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3802,6 +3806,8 @@
E9C32B9B1AB20C5900F283AF /* EAAccessoryManager+SDLProtocols.m */,
E9C32B841AB20B4300F283AF /* NSThread+ThreadIndex.h */,
E9C32B851AB20B4300F283AF /* NSThread+ThreadIndex.m */,
DA318C1D1DD0F06C00C035AC /* NSMutableDictionary+Store.h */,
DA318C1E1DD0F06C00C035AC /* NSMutableDictionary+Store.m */,
);
name = "@categories";
sourceTree = "<group>";
Expand Down Expand Up @@ -3901,6 +3907,7 @@
5D3E48751D6F3B330000BFEF /* SDLAsynchronousOperation.h in Headers */,
DA9F7E631DCBFAC800ACAE48 /* SDLDateTime.h in Headers */,
5D61FCEA1A84238C00846EE7 /* SDLLayoutMode.h in Headers */,
DA318C1F1DD0F06C00C035AC /* NSMutableDictionary+Store.h in Headers */,
5D61FD7F1A84238C00846EE7 /* SDLSetAppIcon.h in Headers */,
5D61FDD11A84238C00846EE7 /* SDLTouchCoord.h in Headers */,
5D61FC7E1A84238C00846EE7 /* SDLDeleteSubMenu.h in Headers */,
Expand Down Expand Up @@ -4575,6 +4582,7 @@
DA9F7E9C1DCC052C00ACAE48 /* SDLLocationDetails.m in Sources */,
5D61FD7A1A84238C00846EE7 /* SDLScreenParams.m in Sources */,
5D61FC831A84238C00846EE7 /* SDLDeviceInfo.m in Sources */,
DA318C201DD0F06C00C035AC /* NSMutableDictionary+Store.m in Sources */,
5D7F87EC1CE3C1A1002DD7C4 /* SDLDeleteFileOperation.m in Sources */,
5D61FD641A84238C00846EE7 /* SDLResetGlobalProperties.m in Sources */,
5D60088B1BE3ED540094A505 /* SDLStateMachine.m in Sources */,
Expand Down
27 changes: 27 additions & 0 deletions SmartDeviceLink/NSMutableDictionary+Store.h
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
65 changes: 65 additions & 0 deletions SmartDeviceLink/NSMutableDictionary+Store.m
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
4 changes: 4 additions & 0 deletions SmartDeviceLink/SDLAbstractTransport.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#import "SDLAbstractTransport.h"

NS_ASSUME_NONNULL_BEGIN

@implementation SDLAbstractTransport

- (instancetype)init {
Expand All @@ -28,3 +30,5 @@ - (double)retryDelay {
}

@end

NS_ASSUME_NONNULL_END
43 changes: 9 additions & 34 deletions SmartDeviceLink/SDLAddCommand.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#import "SDLAddCommand.h"

#import "NSMutableDictionary+Store.h"
#import "SDLImage.h"
#import "SDLMenuParams.h"
#import "SDLNames.h"
Expand Down Expand Up @@ -68,61 +69,35 @@ - (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSStri
}

- (void)setCmdID:(NSNumber<SDLInt> *)cmdID {
if (cmdID != nil) {
[parameters setObject:cmdID forKey:SDLNameCommandId];
} else {
[parameters removeObjectForKey:SDLNameCommandId];
}
[parameters sdl_setObject:cmdID forName:SDLNameCommandId];
}

- (NSNumber<SDLInt> *)cmdID {
return [parameters objectForKey:SDLNameCommandId];
return [parameters sdl_objectForName:SDLNameCommandId];
}

- (void)setMenuParams:(nullable SDLMenuParams *)menuParams {
if (menuParams != nil) {
[parameters setObject:menuParams forKey:SDLNameMenuParams];
} else {
[parameters removeObjectForKey:SDLNameMenuParams];
}
[parameters sdl_setObject:menuParams forName:SDLNameMenuParams];
}

- (nullable SDLMenuParams *)menuParams {
NSObject *obj = [parameters objectForKey:SDLNameMenuParams];
if ([obj isKindOfClass:NSDictionary.class]) {
return [[SDLMenuParams alloc] initWithDictionary:(NSDictionary *)obj];
}

return (SDLMenuParams*)obj;
return [parameters sdl_objectForName:SDLNameMenuParams ofClass:SDLMenuParams.class];
}

- (void)setVrCommands:(nullable NSMutableArray<NSString *> *)vrCommands {
if (vrCommands != nil) {
[parameters setObject:vrCommands forKey:SDLNameVRCommands];
} else {
[parameters removeObjectForKey:SDLNameVRCommands];
}
[parameters sdl_setObject:vrCommands forName:SDLNameVRCommands];
}

- (nullable NSMutableArray<NSString *> *)vrCommands {
return [parameters objectForKey:SDLNameVRCommands];
return [parameters sdl_objectForName:SDLNameVRCommands];
}

- (void)setCmdIcon:(nullable SDLImage *)cmdIcon {
if (cmdIcon != nil) {
[parameters setObject:cmdIcon forKey:SDLNameCommandIcon];
} else {
[parameters removeObjectForKey:SDLNameCommandIcon];
}
[parameters sdl_setObject:cmdIcon forName:SDLNameCommandIcon];
}

- (nullable SDLImage *)cmdIcon {
NSObject *obj = [parameters objectForKey:SDLNameCommandIcon];
if ([obj isKindOfClass:NSDictionary.class]) {
return [[SDLImage alloc] initWithDictionary:(NSDictionary *)obj];
}

return (SDLImage*)obj;
return [parameters sdl_objectForName:SDLNameCommandIcon ofClass:SDLImage.class];
}

@end
Expand Down
1 change: 1 addition & 0 deletions SmartDeviceLink/SDLAddCommandResponse.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#import "SDLAddCommandResponse.h"

#import "NSMutableDictionary+Store.h"
#import "SDLNames.h"

NS_ASSUME_NONNULL_BEGIN
Expand Down
25 changes: 7 additions & 18 deletions SmartDeviceLink/SDLAddSubMenu.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#import "SDLAddSubMenu.h"

#import "NSMutableDictionary+Store.h"
#import "SDLNames.h"

NS_ASSUME_NONNULL_BEGIN
Expand Down Expand Up @@ -39,39 +40,27 @@ - (instancetype)initWithId:(UInt32)menuId menuName:(NSString *)menuName {
}

- (void)setMenuID:(NSNumber<SDLInt> *)menuID {
if (menuID != nil) {
[parameters setObject:menuID forKey:SDLNameMenuId];
} else {
[parameters removeObjectForKey:SDLNameMenuId];
}
[parameters sdl_setObject:menuID forName:SDLNameMenuId];
}

- (NSNumber<SDLInt> *)menuID {
return [parameters objectForKey:SDLNameMenuId];
return [parameters sdl_objectForName:SDLNameMenuId];
}

- (void)setPosition:(nullable NSNumber<SDLInt> *)position {
if (position != nil) {
[parameters setObject:position forKey:SDLNamePosition];
} else {
[parameters removeObjectForKey:SDLNamePosition];
}
[parameters sdl_setObject:position forName:SDLNamePosition];
}

- (nullable NSNumber<SDLInt> *)position {
return [parameters objectForKey:SDLNamePosition];
return [parameters sdl_objectForName:SDLNamePosition];
}

- (void)setMenuName:(NSString *)menuName {
if (menuName != nil) {
[parameters setObject:menuName forKey:SDLNameMenuName];
} else {
[parameters removeObjectForKey:SDLNameMenuName];
}
[parameters sdl_setObject:menuName forName:SDLNameMenuName];
}

- (NSString *)menuName {
return [parameters objectForKey:SDLNameMenuName];
return [parameters sdl_objectForName:SDLNameMenuName];
}

@end
Expand Down
1 change: 1 addition & 0 deletions SmartDeviceLink/SDLAddSubMenuResponse.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#import "SDLAddSubMenuResponse.h"

#import "NSMutableDictionary+Store.h"
#import "SDLNames.h"

NS_ASSUME_NONNULL_BEGIN
Expand Down
Loading

0 comments on commit 69638e1

Please sign in to comment.