diff options
author | Muller, Alexander (A.) <amulle19@ford.com> | 2016-10-20 11:46:37 -0700 |
---|---|---|
committer | Muller, Alexander (A.) <amulle19@ford.com> | 2016-10-20 11:46:37 -0700 |
commit | 74b57f425724aa07f5b09ef7003d1d4cac21065a (patch) | |
tree | 750b357f5e0fc07b1bc57f86ea4410cc2acbd3b3 | |
parent | a277c6e42c672d75e9f5a3f28363f6e3d1c9cdf7 (diff) | |
download | sdl_ios-74b57f425724aa07f5b09ef7003d1d4cac21065a.tar.gz |
rewrote initializers to look nicer.
51 files changed, 539 insertions, 331 deletions
diff --git a/SmartDeviceLink/SDLAddCommand.m b/SmartDeviceLink/SDLAddCommand.m index 4f2c43faf..4920d876f 100644 --- a/SmartDeviceLink/SDLAddCommand.m +++ b/SmartDeviceLink/SDLAddCommand.m @@ -28,38 +28,38 @@ return self; } -- (instancetype)initWithId:(NSNumber *)commandId vrCommands:(NSArray *)vrCommands handler:(SDLRPCNotificationHandler)handler { - if (self = [self initWithId:commandId menuName:nil vrCommands:vrCommands handler:handler]) { +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { } return self; } +- (instancetype)initWithId:(NSNumber *)commandId vrCommands:(NSArray *)vrCommands handler:(SDLRPCNotificationHandler)handler { + return [self initWithId:commandId menuName:nil vrCommands:vrCommands handler:handler]; +} + - (instancetype)initWithId:(NSNumber *)commandId menuName:(NSString *)menuName vrCommands:(NSArray *)vrCommands handler:(SDLRPCNotificationHandler)handler { - if (self = [self initWithId:commandId menuName:menuName parentId:nil position:nil vrCommands:vrCommands iconValue:nil iconType:nil handler:handler]) { - } - return self; + return [self initWithId:commandId menuName:menuName parentId:nil position:nil vrCommands:vrCommands iconValue:nil iconType:nil handler:handler]; } - (instancetype)initWithId:(NSNumber *)commandId menuName:(NSString *)menuName parentId:(NSNumber *)parentId position:(NSNumber *)position vrCommands:(NSArray *)vrCommands iconValue:(NSString *)iconValue iconType:(SDLImageType *)iconType handler:(SDLRPCNotificationHandler)handler { - if (self = [self initWithHandler:handler]) { - self.cmdID = commandId; - - if (menuName != nil || parentId != nil || position != nil) { - self.menuParams = [[SDLMenuParams alloc] initWithMenuName:menuName parentId:parentId position:position]; - } - - self.vrCommands = [vrCommands mutableCopy]; - - if (iconValue != nil || iconType != nil) { - self.cmdIcon = [[SDLImage alloc] initWithName:iconValue ofType:iconType]; - } + self = [self initWithHandler:handler]; + if (!self) { + return nil; } - return self; -} - -- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { - if (self = [super initWithDictionary:dict]) { + + self.cmdID = commandId; + + if (menuName != nil || parentId != nil || position != nil) { + self.menuParams = [[SDLMenuParams alloc] initWithMenuName:menuName parentId:parentId.unsignedIntegerValue position:position.unsignedIntegerValue]; + } + + self.vrCommands = [vrCommands mutableCopy]; + + if (iconValue != nil || iconType != nil) { + self.cmdIcon = [[SDLImage alloc] initWithName:iconValue ofType:iconType]; } + return self; } diff --git a/SmartDeviceLink/SDLAddSubMenu.m b/SmartDeviceLink/SDLAddSubMenu.m index ca3aa1a30..f30a23c16 100644 --- a/SmartDeviceLink/SDLAddSubMenu.m +++ b/SmartDeviceLink/SDLAddSubMenu.m @@ -19,17 +19,19 @@ } - (instancetype)initWithId:(NSNumber *)menuId menuName:(NSString *)menuName { - if (self = [self initWithId:menuId menuName:menuName position:nil]) { - } - return self; + return [self initWithId:menuId menuName:menuName position:nil]; } - (instancetype)initWithId:(NSNumber *)menuId menuName:(NSString *)menuName position:(NSNumber *)position { - if (self = [self init]) { - self.menuID = menuId; - self.menuName = menuName; - self.position = position; + self = [self init]; + if (!self) { + return nil; } + + self.menuID = menuId; + self.menuName = menuName; + self.position = position; + return self; } diff --git a/SmartDeviceLink/SDLAlert.m b/SmartDeviceLink/SDLAlert.m index ba1106d1e..789fd7bf9 100644 --- a/SmartDeviceLink/SDLAlert.m +++ b/SmartDeviceLink/SDLAlert.m @@ -22,58 +22,48 @@ } - (instancetype)initWithAlertText1:(NSString *)alertText1 alertText2:(NSString *)alertText2 duration:(NSNumber *)duration { - if (self = [self initWithAlertText1:alertText1 alertText2:alertText2 alertText3:nil duration:duration]) { - } - return self; + return [self initWithAlertText1:alertText1 alertText2:alertText2 alertText3:nil duration:duration]; } - (instancetype)initWithAlertText1:(NSString *)alertText1 alertText2:(NSString *)alertText2 alertText3:(NSString *)alertText3 duration:(NSNumber *)duration { - if (self = [self initWithAlertText1:alertText1 alertText2:alertText2 alertText3:alertText3 duration:duration softButtons:nil]) { - } - return self; + return [self initWithAlertText1:alertText1 alertText2:alertText2 alertText3:alertText3 duration:duration softButtons:nil]; } - (instancetype)initWithAlertText1:(NSString *)alertText1 alertText2:(NSString *)alertText2 alertText3:(NSString *)alertText3 duration:(NSNumber *)duration softButtons:(NSArray *)softButtons { - if (self = [self initWithTTSChunks:nil alertText1:alertText1 alertText2:alertText2 alertText3:alertText3 playTone:NO duration:duration softButtons:softButtons]) { - } - return self; + return [self initWithTTSChunks:nil alertText1:alertText1 alertText2:alertText2 alertText3:alertText3 playTone:NO duration:duration softButtons:softButtons]; } - (instancetype)initWithTTS:(NSString *)ttsText playTone:(BOOL)playTone { - if (self = [self initWithTTS:ttsText alertText1:nil alertText2:nil playTone:playTone duration:nil]) { - } - return self; + return [self initWithTTS:ttsText alertText1:nil alertText2:nil playTone:playTone duration:nil]; } - (instancetype)initWithTTS:(NSString *)ttsText alertText1:(NSString *)alertText1 alertText2:(NSString *)alertText2 playTone:(BOOL)playTone duration:(NSNumber *)duration { - if (self = [self initWithTTS:ttsText alertText1:alertText1 alertText2:alertText2 alertText3:nil playTone:playTone duration:duration]) { - } - return self; + return [self initWithTTS:ttsText alertText1:alertText1 alertText2:alertText2 alertText3:nil playTone:playTone duration:duration]; } - (instancetype)initWithTTS:(NSString *)ttsText alertText1:(NSString *)alertText1 alertText2:(NSString *)alertText2 alertText3:(NSString *)alertText3 playTone:(BOOL)playTone duration:(NSNumber *)duration { NSMutableArray* ttsChunks = [SDLTTSChunkFactory buildTTSChunksFromSimple:ttsText]; - if (self = [self initWithTTSChunks:ttsChunks alertText1:alertText1 alertText2:alertText2 alertText3:alertText3 playTone:playTone duration:duration softButtons:nil]) { - } - return self; + return [self initWithTTSChunks:ttsChunks alertText1:alertText1 alertText2:alertText2 alertText3:alertText3 playTone:playTone duration:duration softButtons:nil]; } - (instancetype)initWithTTSChunks:(NSArray *)ttsChunks playTone:(BOOL)playTone { - if (self = [self initWithTTSChunks:ttsChunks alertText1:nil alertText2:nil alertText3:nil playTone:playTone duration:nil softButtons:nil]) { - } - return self; + return [self initWithTTSChunks:ttsChunks alertText1:nil alertText2:nil alertText3:nil playTone:playTone duration:nil softButtons:nil]; } - (instancetype)initWithTTSChunks:(NSArray *)ttsChunks alertText1:(NSString *)alertText1 alertText2:(NSString *)alertText2 alertText3:(NSString *)alertText3 playTone:(BOOL)playTone duration:(NSNumber *)duration softButtons:(NSArray *)softButtons { - if (self = [self init]) { - self.ttsChunks = [ttsChunks mutableCopy]; - self.alertText1 = alertText1; - self.alertText2 = alertText2; - self.alertText3 = alertText3; - self.playTone = @(playTone); - self.duration = duration; - self.softButtons = [softButtons mutableCopy]; - } + self = [self init]; + if (!self) { + return nil; + } + + self.ttsChunks = [ttsChunks mutableCopy]; + self.alertText1 = alertText1; + self.alertText2 = alertText2; + self.alertText3 = alertText3; + self.playTone = @(playTone); + self.duration = duration; + self.softButtons = [softButtons mutableCopy]; + return self; } diff --git a/SmartDeviceLink/SDLAlertManeuver.m b/SmartDeviceLink/SDLAlertManeuver.m index ad7ff5252..ab29bde16 100644 --- a/SmartDeviceLink/SDLAlertManeuver.m +++ b/SmartDeviceLink/SDLAlertManeuver.m @@ -25,16 +25,18 @@ - (instancetype)initWithTTS:(NSString *)ttsText softButtons:(NSArray *)softButtons { NSMutableArray* ttsChunks = [SDLTTSChunkFactory buildTTSChunksFromSimple:ttsText]; - if (self = [self initWithTTSChunks:ttsChunks softButtons:softButtons]) { - } - return self; + return [self initWithTTSChunks:ttsChunks softButtons:softButtons]; } - (instancetype)initWithTTSChunks:(NSArray *)ttsChunks softButtons:(NSArray *)softButtons { - if (self = [self init]) { - self.ttsChunks = [ttsChunks mutableCopy]; - self.softButtons = [softButtons mutableCopy]; + self = [self init]; + if (!self) { + return nil; } + + self.ttsChunks = [ttsChunks mutableCopy]; + self.softButtons = [softButtons mutableCopy]; + return self; } diff --git a/SmartDeviceLink/SDLChangeRegistration.m b/SmartDeviceLink/SDLChangeRegistration.m index 8acef3b7d..a9445ba99 100644 --- a/SmartDeviceLink/SDLChangeRegistration.m +++ b/SmartDeviceLink/SDLChangeRegistration.m @@ -22,10 +22,14 @@ } - (instancetype)initWithLanguage:(SDLLanguage *)language hmiDisplayLanguage:(SDLLanguage *)hmiDisplayLanguage { - if (self = [self init]) { - self.language = language; - self.hmiDisplayLanguage = hmiDisplayLanguage; + self = [self init]; + if (!self) { + return nil; } + + self.language = language; + self.hmiDisplayLanguage = hmiDisplayLanguage; + return self; } diff --git a/SmartDeviceLink/SDLChoice.h b/SmartDeviceLink/SDLChoice.h index 478b33b5f..cd8729d38 100644 --- a/SmartDeviceLink/SDLChoice.h +++ b/SmartDeviceLink/SDLChoice.h @@ -64,6 +64,8 @@ */ - (instancetype)initWithDictionary:(NSMutableDictionary *)dict; +- (instancetype)initWithId:(NSUInteger)choiceId menuName:(NSString*)menuName vrCommands:(NSArray*)vrCommands image:(SDLImage*)image secondaryText:(NSString*)secondaryText secondaryImage:(SDLImage*)secondaryImage tertiaryText:(NSString*)tertiaryText; + /** * @abstract the application-scoped identifier that uniquely identifies this choice * diff --git a/SmartDeviceLink/SDLChoice.m b/SmartDeviceLink/SDLChoice.m index 83e1d56ae..2b99d4a0c 100644 --- a/SmartDeviceLink/SDLChoice.m +++ b/SmartDeviceLink/SDLChoice.m @@ -21,6 +21,23 @@ return self; } +- (instancetype)initWithId:(NSUInteger)choiceId menuName:(NSString*)menuName vrCommands:(NSArray*)vrCommands image:(SDLImage*)image secondaryText:(NSString*)secondaryText secondaryImage:(SDLImage*)secondaryImage tertiaryText:(NSString*)tertiaryText { + self = [self init]; + if (!self) { + return nil; + } + + self.choiceID = @(choiceId); + self.menuName = menuName; + self.vrCommands = [vrCommands mutableCopy]; + self.image = image; + self.secondaryText = secondaryText; + self.secondaryImage = secondaryImage; + self.tertiaryText = tertiaryText; + + return self; +} + - (void)setChoiceID:(NSNumber *)choiceID { if (choiceID != nil) { [store setObject:choiceID forKey:NAMES_choiceID]; diff --git a/SmartDeviceLink/SDLCreateInteractionChoiceSet.m b/SmartDeviceLink/SDLCreateInteractionChoiceSet.m index 603feed05..e42ca299e 100644 --- a/SmartDeviceLink/SDLCreateInteractionChoiceSet.m +++ b/SmartDeviceLink/SDLCreateInteractionChoiceSet.m @@ -22,10 +22,13 @@ } - (instancetype)initWithId:(NSInteger)choiceId choiceSet:(NSArray *)choiceSet { - if (self = [self init]) { - self.interactionChoiceSetID = @(choiceId); - self.choiceSet = [choiceSet mutableCopy]; + self = [self init]; + if (!self) { + return nil; } + + self.interactionChoiceSetID = @(choiceId); + self.choiceSet = [choiceSet mutableCopy]; return self; } diff --git a/SmartDeviceLink/SDLDeleteCommand.m b/SmartDeviceLink/SDLDeleteCommand.m index 28bd130c0..981d7105c 100644 --- a/SmartDeviceLink/SDLDeleteCommand.m +++ b/SmartDeviceLink/SDLDeleteCommand.m @@ -21,9 +21,13 @@ } - (instancetype)initWithId:(NSInteger)commandId { - if (self = [self init]) { - self.cmdID = @(commandId); + self = [self init]; + if (!self) { + return nil; } + + self.cmdID = @(commandId); + return self; } diff --git a/SmartDeviceLink/SDLDeleteFile.m b/SmartDeviceLink/SDLDeleteFile.m index ee659f408..355033c73 100644 --- a/SmartDeviceLink/SDLDeleteFile.m +++ b/SmartDeviceLink/SDLDeleteFile.m @@ -21,9 +21,13 @@ } - (instancetype)initWithFileName:(NSString *)fileName { - if (self = [self init]) { - self.syncFileName = fileName; + self = [self init]; + if (!self) { + return nil; } + + self.syncFileName = fileName; + return self; } diff --git a/SmartDeviceLink/SDLDeleteInteractionChoiceSet.m b/SmartDeviceLink/SDLDeleteInteractionChoiceSet.m index 9a9848a82..a74e874d2 100644 --- a/SmartDeviceLink/SDLDeleteInteractionChoiceSet.m +++ b/SmartDeviceLink/SDLDeleteInteractionChoiceSet.m @@ -21,9 +21,13 @@ } - (instancetype)initWithId:(NSInteger)choiceId { - if (self = [self init]) { - self.interactionChoiceSetID = @(choiceId); + self = [self init]; + if (!self) { + return nil; } + + self.interactionChoiceSetID = @(choiceId); + return self; } diff --git a/SmartDeviceLink/SDLDeleteSubMenu.m b/SmartDeviceLink/SDLDeleteSubMenu.m index 4d1aa3dbe..cefe9e34a 100644 --- a/SmartDeviceLink/SDLDeleteSubMenu.m +++ b/SmartDeviceLink/SDLDeleteSubMenu.m @@ -21,9 +21,13 @@ } - (instancetype)initWithId:(NSInteger)menuId { - if (self = [self init]) { - self.menuID = @(menuId); + self = [self init]; + if (!self) { + return nil; } + + self.menuID = @(menuId); + return self; } diff --git a/SmartDeviceLink/SDLDiagnosticMessage.h b/SmartDeviceLink/SDLDiagnosticMessage.h index 40ca013f2..f7930a695 100644 --- a/SmartDeviceLink/SDLDiagnosticMessage.h +++ b/SmartDeviceLink/SDLDiagnosticMessage.h @@ -15,6 +15,8 @@ - (instancetype)init; - (instancetype)initWithDictionary:(NSMutableDictionary *)dict; +- (instancetype)initWithTargetId:(NSUInteger)targetId length:(NSUInteger)length data:(NSArray*)data; + /** * Name of target ECU * diff --git a/SmartDeviceLink/SDLDiagnosticMessage.m b/SmartDeviceLink/SDLDiagnosticMessage.m index 8a45a8650..28c728d3d 100644 --- a/SmartDeviceLink/SDLDiagnosticMessage.m +++ b/SmartDeviceLink/SDLDiagnosticMessage.m @@ -20,6 +20,19 @@ return self; } +- (instancetype)initWithTargetId:(NSUInteger)targetId length:(NSUInteger)length data:(NSArray*)data { + self = [self init]; + if (!self) { + return nil; + } + + self.targetID = @(targetId); + self.messageLength = @(length); + self.messageData = [data mutableCopy]; + + return self; +} + - (void)setTargetID:(NSNumber *)targetID { if (targetID != nil) { [parameters setObject:targetID forKey:NAMES_targetID]; diff --git a/SmartDeviceLink/SDLDialNumber.m b/SmartDeviceLink/SDLDialNumber.m index e6704a14d..2bc41beb5 100644 --- a/SmartDeviceLink/SDLDialNumber.m +++ b/SmartDeviceLink/SDLDialNumber.m @@ -21,9 +21,13 @@ } - (instancetype)initWithNumber:(NSString *)number { - if (self = [self init]) { - self.number = number; + self = [self init]; + if (!self) { + return nil; } + + self.number = number; + return self; } diff --git a/SmartDeviceLink/SDLGetDTCs.m b/SmartDeviceLink/SDLGetDTCs.m index f699542b7..fe247e2f1 100644 --- a/SmartDeviceLink/SDLGetDTCs.m +++ b/SmartDeviceLink/SDLGetDTCs.m @@ -21,9 +21,13 @@ } - (instancetype)initWithECUName:(NSInteger)name { - if (self = [self init]) { - self.ecuName = @(name); + self = [self init]; + if (!self) { + return nil; } + + self.ecuName = @(name); + return self; } diff --git a/SmartDeviceLink/SDLGetVehicleData.m b/SmartDeviceLink/SDLGetVehicleData.m index 4477ec072..c79da6c6b 100644 --- a/SmartDeviceLink/SDLGetVehicleData.m +++ b/SmartDeviceLink/SDLGetVehicleData.m @@ -21,33 +21,37 @@ } - (instancetype)initWithAccelerationPedalPosition:(BOOL)accelerationPedalPosition airbagStatus:(BOOL)airbagStatus beltStatus:(BOOL)beltStatus bodyInformation:(BOOL)bodyInformation clusterModeStatus:(BOOL)clusterModeStatus deviceStatus:(BOOL)deviceStatus driverBraking:(BOOL)driverBraking eCallInfo:(BOOL)eCallInfo emergencyEvent:(BOOL)emergencyEvent engineTorque:(BOOL)engineTorque externalTemperature:(BOOL)externalTemperature fuelLevel:(BOOL)fuelLevel fuelLevelState:(BOOL)fuelLevelState gps:(BOOL)gps headLampStatus:(BOOL)headLampStatus instantFuelConsumption:(BOOL)instantFuelConsumption myKey:(BOOL)myKey odometer:(BOOL)odometer prndl:(BOOL)prndl rpm:(BOOL)rpm speed:(BOOL)speed steeringWheelAngle:(BOOL)steeringWheelAngle tirePressure:(BOOL)tirePressure vin:(BOOL)vin wiperStatus:(BOOL)wiperStatus { - if (self = [self init]) { - self.accPedalPosition = @(accelerationPedalPosition); - self.airbagStatus = @(airbagStatus); - self.beltStatus = @(beltStatus); - self.bodyInformation = @(bodyInformation); - self.clusterModeStatus = @(clusterModeStatus); - self.deviceStatus = @(deviceStatus); - self.driverBraking = @(driverBraking); - self.eCallInfo = @(eCallInfo); - self.emergencyEvent = @(emergencyEvent); - self.engineTorque = @(engineTorque); - self.externalTemperature = @(externalTemperature); - self.fuelLevel = @(fuelLevel); - self.fuelLevel_State = @(fuelLevelState); - self.myKey = @(myKey); - self.odometer = @(odometer); - self.gps = @(gps); - self.headLampStatus = @(headLampStatus); - self.instantFuelConsumption = @(instantFuelConsumption); - self.prndl = @(prndl); - self.rpm = @(rpm); - self.speed = @(speed); - self.steeringWheelAngle = @(steeringWheelAngle); - self.tirePressure = @(tirePressure); - self.vin = @(vin); - self.wiperStatus = @(wiperStatus); + self = [self init]; + if (!self) { + return nil; } + + self.accPedalPosition = @(accelerationPedalPosition); + self.airbagStatus = @(airbagStatus); + self.beltStatus = @(beltStatus); + self.bodyInformation = @(bodyInformation); + self.clusterModeStatus = @(clusterModeStatus); + self.deviceStatus = @(deviceStatus); + self.driverBraking = @(driverBraking); + self.eCallInfo = @(eCallInfo); + self.emergencyEvent = @(emergencyEvent); + self.engineTorque = @(engineTorque); + self.externalTemperature = @(externalTemperature); + self.fuelLevel = @(fuelLevel); + self.fuelLevel_State = @(fuelLevelState); + self.myKey = @(myKey); + self.odometer = @(odometer); + self.gps = @(gps); + self.headLampStatus = @(headLampStatus); + self.instantFuelConsumption = @(instantFuelConsumption); + self.prndl = @(prndl); + self.rpm = @(rpm); + self.speed = @(speed); + self.steeringWheelAngle = @(steeringWheelAngle); + self.tirePressure = @(tirePressure); + self.vin = @(vin); + self.wiperStatus = @(wiperStatus); + return self; } diff --git a/SmartDeviceLink/SDLImage.m b/SmartDeviceLink/SDLImage.m index 342dbaf16..734f0e475 100644 --- a/SmartDeviceLink/SDLImage.m +++ b/SmartDeviceLink/SDLImage.m @@ -22,10 +22,14 @@ } - (instancetype)initWithName:(NSString *)name ofType:(SDLImageType *)imageType { - if (self = [super init]) { - self.value = name; - self.imageType = imageType; + self = [self init]; + if (!self) { + return nil; } + + self.value = name; + self.imageType = imageType; + return self; } diff --git a/SmartDeviceLink/SDLKeyboardProperties.h b/SmartDeviceLink/SDLKeyboardProperties.h index 8215a8938..f13c4c226 100644 --- a/SmartDeviceLink/SDLKeyboardProperties.h +++ b/SmartDeviceLink/SDLKeyboardProperties.h @@ -14,6 +14,8 @@ - (instancetype)init; - (instancetype)initWithDictionary:(NSMutableDictionary *)dict; +- (instancetype)initWithLanguage:(SDLLanguage*)language layout:(SDLKeyboardLayout*)layout keypressMode:(SDLKeypressMode*)keypressMode limitedCharacterList:(NSArray*)limitedCharacterList autoCompleteText:(NSString*)autoCompleteText; + @property (strong) SDLLanguage *language; @property (strong) SDLKeyboardLayout *keyboardLayout; @property (strong) SDLKeypressMode *keypressMode; diff --git a/SmartDeviceLink/SDLKeyboardProperties.m b/SmartDeviceLink/SDLKeyboardProperties.m index 896f3a99a..46849a7d5 100644 --- a/SmartDeviceLink/SDLKeyboardProperties.m +++ b/SmartDeviceLink/SDLKeyboardProperties.m @@ -23,6 +23,21 @@ return self; } +- (instancetype)initWithLanguage:(SDLLanguage*)language layout:(SDLKeyboardLayout*)layout keypressMode:(SDLKeypressMode*)keypressMode limitedCharacterList:(NSArray*)limitedCharacterList autoCompleteText:(NSString*)autoCompleteText { + self = [self init]; + if (!self) { + return nil; + } + + self.language = language; + self.keyboardLayout = layout; + self.keypressMode = keypressMode; + self.limitedCharacterList = [limitedCharacterList mutableCopy]; + self.autoCompleteText = autoCompleteText; + + return self; +} + - (void)setLanguage:(SDLLanguage *)language { if (language != nil) { [store setObject:language forKey:NAMES_language]; diff --git a/SmartDeviceLink/SDLMenuParams.h b/SmartDeviceLink/SDLMenuParams.h index d0376e45d..f8076c4a2 100644 --- a/SmartDeviceLink/SDLMenuParams.h +++ b/SmartDeviceLink/SDLMenuParams.h @@ -23,7 +23,9 @@ */ - (instancetype)initWithDictionary:(NSMutableDictionary *)dict; -- (instancetype)initWithMenuName:(NSString *)menuName parentId:(NSNumber *)parentId position:(NSNumber *)position; +- (instancetype)initWithMenuName:(NSString*)menuName; + +- (instancetype)initWithMenuName:(NSString *)menuName parentId:(NSUInteger)parentId position:(NSUInteger)position; /** * @abstract the unique ID of an existing submenu to which a command will be added diff --git a/SmartDeviceLink/SDLMenuParams.m b/SmartDeviceLink/SDLMenuParams.m index 8ff27a68a..a64a6518d 100644 --- a/SmartDeviceLink/SDLMenuParams.m +++ b/SmartDeviceLink/SDLMenuParams.m @@ -20,12 +20,26 @@ return self; } -- (instancetype)initWithMenuName:(NSString *)menuName parentId:(NSNumber *)parentId position:(NSNumber *)position { - if (self = [self init]) { - self.menuName = menuName; - self.parentID = parentId; - self.position = position; +- (instancetype)initWithMenuName:(NSString *)menuName parentId:(NSUInteger)parentId position:(NSUInteger)position { + self = [self initWithMenuName:menuName]; + if (!self) { + return nil; } + + self.parentID = @(parentId); + self.position = @(parentId); + + return self; +} + +- (instancetype)initWithMenuName:(NSString *)menuName { + self = [self init]; + if (!self) { + return nil; + } + + self.menuName = menuName; + return self; } diff --git a/SmartDeviceLink/SDLPerformAudioPassThru.m b/SmartDeviceLink/SDLPerformAudioPassThru.m index 8f3d188d3..80a9dd4e3 100644 --- a/SmartDeviceLink/SDLPerformAudioPassThru.m +++ b/SmartDeviceLink/SDLPerformAudioPassThru.m @@ -27,16 +27,20 @@ } - (instancetype)initWithInitialPrompt:(NSString *)initialPrompt audioPassThruDisplayText1:(NSString *)audioPassThruDisplayText1 audioPassThruDisplayText2:(NSString *)audioPassThruDisplayText2 samplingRate:(SDLSamplingRate *)samplingRate maxDuration:(NSNumber *)maxDuration bitsPerSample:(SDLBitsPerSample *)bitsPerSample audioType:(SDLAudioType *)audioType muteAudio:(BOOL)muteAudio { - if (self = [self init]) { - self.initialPrompt = [SDLTTSChunkFactory buildTTSChunksFromSimple:initialPrompt]; - self.audioPassThruDisplayText1 = audioPassThruDisplayText1; - self.audioPassThruDisplayText2 = audioPassThruDisplayText2; - self.samplingRate = samplingRate; - self.maxDuration = maxDuration; - self.bitsPerSample = bitsPerSample; - self.audioType = audioType; - self.muteAudio = @(muteAudio); + self = [self init]; + if (!self) { + return nil; } + + self.initialPrompt = [SDLTTSChunkFactory buildTTSChunksFromSimple:initialPrompt]; + self.audioPassThruDisplayText1 = audioPassThruDisplayText1; + self.audioPassThruDisplayText2 = audioPassThruDisplayText2; + self.samplingRate = samplingRate; + self.maxDuration = maxDuration; + self.bitsPerSample = bitsPerSample; + self.audioType = audioType; + self.muteAudio = @(muteAudio); + return self; } diff --git a/SmartDeviceLink/SDLPerformInteraction.m b/SmartDeviceLink/SDLPerformInteraction.m index 5c268c098..c7a344d09 100644 --- a/SmartDeviceLink/SDLPerformInteraction.m +++ b/SmartDeviceLink/SDLPerformInteraction.m @@ -26,43 +26,39 @@ } - (instancetype)initWithInitialPrompt:(NSString *)initialPrompt initialText:(NSString *)initialText interactionChoiceSetID:(NSNumber *)interactionChoiceSetID { - if (self = [self initWithInitialPrompt:initialPrompt initialText:initialText interactionChoiceSetID:interactionChoiceSetID vrHelp:nil]) { - } - return self; + return [self initWithInitialPrompt:initialPrompt initialText:initialText interactionChoiceSetID:interactionChoiceSetID vrHelp:nil]; } - (instancetype)initWithInitialPrompt:(NSString *)initialPrompt initialText:(NSString *)initialText interactionChoiceSetID:(NSNumber *)interactionChoiceSetID vrHelp:(NSArray *)vrHelp { - if (self = [self initWithInitialPrompt:initialPrompt initialText:initialText interactionChoiceSetIDList:@[interactionChoiceSetID] helpPrompt:nil timeoutPrompt:nil interactionMode:nil timeout:nil vrHelp:vrHelp]) { - } - return self; + return [self initWithInitialPrompt:initialPrompt initialText:initialText interactionChoiceSetIDList:@[interactionChoiceSetID] helpPrompt:nil timeoutPrompt:nil interactionMode:nil timeout:nil vrHelp:vrHelp]; } - (instancetype)initWithInitialPrompt:(NSString *)initialPrompt initialText:(NSString *)initialText interactionChoiceSetIDList:(NSArray *)interactionChoiceSetIDList helpPrompt:(NSString *)helpPrompt timeoutPrompt:(NSString *)timeoutPrompt interactionMode:(SDLInteractionMode *)interactionMode timeout:(NSNumber *)timeout { - if (self = [self initWithInitialPrompt:initialPrompt initialText:initialText interactionChoiceSetIDList:interactionChoiceSetIDList helpPrompt:helpPrompt timeoutPrompt:timeoutPrompt interactionMode:interactionMode timeout:timeout vrHelp:nil]) { - } - return self; + return [self initWithInitialPrompt:initialPrompt initialText:initialText interactionChoiceSetIDList:interactionChoiceSetIDList helpPrompt:helpPrompt timeoutPrompt:timeoutPrompt interactionMode:interactionMode timeout:timeout vrHelp:nil]; } - (instancetype)initWithInitialPrompt:(NSString *)initialPrompt initialText:(NSString *)initialText interactionChoiceSetIDList:(NSArray *)interactionChoiceSetIDList helpPrompt:(NSString *)helpPrompt timeoutPrompt:(NSString *)timeoutPrompt interactionMode:(SDLInteractionMode *)interactionMode timeout:(NSNumber *)timeout vrHelp:(NSArray *)vrHelp { NSMutableArray* initialChunks = [SDLTTSChunkFactory buildTTSChunksFromSimple:initialPrompt]; NSMutableArray* helpChunks = [SDLTTSChunkFactory buildTTSChunksFromSimple:helpPrompt]; NSMutableArray* timeoutChunks = [SDLTTSChunkFactory buildTTSChunksFromSimple:timeoutPrompt]; - if (self = [self initWithInitialChunks:initialChunks initialText:initialText interactionChoiceSetIDList:interactionChoiceSetIDList helpChunks:helpChunks timeoutChunks:timeoutChunks interactionMode:interactionMode timeout:timeout vrHelp:vrHelp]) { - } - return self; + return [self initWithInitialChunks:initialChunks initialText:initialText interactionChoiceSetIDList:interactionChoiceSetIDList helpChunks:helpChunks timeoutChunks:timeoutChunks interactionMode:interactionMode timeout:timeout vrHelp:vrHelp]; } - (instancetype)initWithInitialChunks:(NSArray *)initialChunks initialText:(NSString *)initialText interactionChoiceSetIDList:(NSArray *)interactionChoiceSetIDList helpChunks:(NSArray *)helpChunks timeoutChunks:(NSArray *)timeoutChunks interactionMode:(SDLInteractionMode *)interactionMode timeout:(NSNumber *)timeout vrHelp:(NSArray *)vrHelp { - if (self = [self init]) { - self.initialPrompt = [initialChunks mutableCopy]; - self.initialText = initialText; - self.interactionChoiceSetIDList = [interactionChoiceSetIDList mutableCopy]; - self.helpPrompt = [helpChunks mutableCopy]; - self.timeoutPrompt = [timeoutChunks mutableCopy]; - self.interactionMode = interactionMode; - self.timeout = timeout; - self.vrHelp = [vrHelp mutableCopy]; - } + self = [self init]; + if (!self) { + return nil; + } + + self.initialPrompt = [initialChunks mutableCopy]; + self.initialText = initialText; + self.interactionChoiceSetIDList = [interactionChoiceSetIDList mutableCopy]; + self.helpPrompt = [helpChunks mutableCopy]; + self.timeoutPrompt = [timeoutChunks mutableCopy]; + self.interactionMode = interactionMode; + self.timeout = timeout; + self.vrHelp = [vrHelp mutableCopy]; + return self; } diff --git a/SmartDeviceLink/SDLPutFile.m b/SmartDeviceLink/SDLPutFile.m index a9f6aaeac..c80fe0638 100644 --- a/SmartDeviceLink/SDLPutFile.m +++ b/SmartDeviceLink/SDLPutFile.m @@ -22,11 +22,15 @@ } - (instancetype)initWithFileName:(NSString *)fileName fileType:(SDLFileType *)fileType persistentFile:(BOOL)persistentFile { - if (self = [self init]) { - self.syncFileName = fileName; - self.fileType = fileType; - self.persistentFile = @(persistentFile); + self = [self init]; + if (!self) { + return nil; } + + self.syncFileName = fileName; + self.fileType = fileType; + self.persistentFile = @(persistentFile); + return self; } diff --git a/SmartDeviceLink/SDLReadDID.m b/SmartDeviceLink/SDLReadDID.m index 9720944c5..eb276aaee 100644 --- a/SmartDeviceLink/SDLReadDID.m +++ b/SmartDeviceLink/SDLReadDID.m @@ -21,10 +21,14 @@ } - (instancetype)initWithECUName:(NSNumber *)ecuName didLocation:(NSArray *)didLocation { - if (self = [self init]) { - self.ecuName = ecuName; - self.didLocation = [didLocation mutableCopy]; + self = [self init]; + if (!self) { + return nil; } + + self.ecuName = ecuName; + self.didLocation = [didLocation mutableCopy]; + return self; } diff --git a/SmartDeviceLink/SDLRegisterAppInterface.m b/SmartDeviceLink/SDLRegisterAppInterface.m index cfc6b27a5..0e0f78e53 100644 --- a/SmartDeviceLink/SDLRegisterAppInterface.m +++ b/SmartDeviceLink/SDLRegisterAppInterface.m @@ -28,31 +28,31 @@ } - (instancetype)initWithAppName:(NSString *)appName languageDesired:(SDLLanguage *)languageDesired appId:(NSString *)appId { - if (self = [self initWithAppName:appName isMediaApp:@NO languageDesired:languageDesired appId:appId]) { - } - return self; + return [self initWithAppName:appName isMediaApp:@NO languageDesired:languageDesired appId:appId]; } - (instancetype)initWithAppName:(NSString *)appName isMediaApp:(BOOL)isMediaApp languageDesired:(SDLLanguage *)languageDesired appId:(NSString *)appId { - if (self = [self initWithAppName:appName ttsName:nil vrSynonyms:@[appName] isMediaApp:isMediaApp languageDesired:languageDesired hmiDisplayLanguageDesired:languageDesired appId:appId]) { - } - return self; + return [self initWithAppName:appName ttsName:nil vrSynonyms:@[appName] isMediaApp:isMediaApp languageDesired:languageDesired hmiDisplayLanguageDesired:languageDesired appId:appId]; } - (instancetype)initWithAppName:(NSString *)appName ttsName:(NSArray *)ttsName vrSynonyms:(NSArray *)vrSynonyms isMediaApp:(BOOL)isMediaApp languageDesired:(SDLLanguage *)languageDesired hmiDisplayLanguageDesired:(SDLLanguage *)hmiDisplayLanguageDesired appId:(NSString *)appId { - if (self = [self init]) { - self.appID = appId; - self.appName = appName; - self.hmiDisplayLanguageDesired = hmiDisplayLanguageDesired; - self.isMediaApplication = @(isMediaApp); - self.ngnMediaScreenAppName = appName; - self.ttsName = [ttsName copy]; - self.vrSynonyms = [vrSynonyms copy]; - self.syncMsgVersion = [[SDLSyncMsgVersion alloc] initWithMajorVersion:1 minorVersion:0]; - self.appInfo = [SDLAppInfo currentAppInfo]; - self.deviceInfo = [SDLDeviceInfo currentDevice]; - self.correlationID = @1; + self = [self init]; + if (!self) { + return nil; } + + self.appID = appId; + self.appName = appName; + self.hmiDisplayLanguageDesired = hmiDisplayLanguageDesired; + self.isMediaApplication = @(isMediaApp); + self.ngnMediaScreenAppName = appName; + self.ttsName = [ttsName copy]; + self.vrSynonyms = [vrSynonyms copy]; + self.syncMsgVersion = [[SDLSyncMsgVersion alloc] initWithMajorVersion:1 minorVersion:0]; + self.appInfo = [SDLAppInfo currentAppInfo]; + self.deviceInfo = [SDLDeviceInfo currentDevice]; + self.correlationID = @1; + return self; } diff --git a/SmartDeviceLink/SDLResetGlobalProperties.m b/SmartDeviceLink/SDLResetGlobalProperties.m index 44e43500a..795523206 100644 --- a/SmartDeviceLink/SDLResetGlobalProperties.m +++ b/SmartDeviceLink/SDLResetGlobalProperties.m @@ -22,9 +22,13 @@ } - (instancetype)initWithProperties:(NSArray *)properties { - if (self = [self init]) { - self.properties = [properties mutableCopy]; + self = [self init]; + if (!self) { + return nil; } + + self.properties = [properties mutableCopy]; + return self; } diff --git a/SmartDeviceLink/SDLScrollableMessage.m b/SmartDeviceLink/SDLScrollableMessage.m index 79b5d5aa0..567210c80 100644 --- a/SmartDeviceLink/SDLScrollableMessage.m +++ b/SmartDeviceLink/SDLScrollableMessage.m @@ -22,11 +22,15 @@ } - (instancetype)initWithMessage:(NSString *)message timeout:(NSNumber *)timeout softButtons:(NSArray *)softButtons { - if (self = [self init]) { - self.scrollableMessageBody = message; - self.timeout = timeout; - self.softButtons = [softButtons mutableCopy]; + self = [self init]; + if (!self) { + return nil; } + + self.scrollableMessageBody = message; + self.timeout = timeout; + self.softButtons = [softButtons mutableCopy]; + return self; } diff --git a/SmartDeviceLink/SDLSendLocation.m b/SmartDeviceLink/SDLSendLocation.m index afdfcf809..211ce2e96 100644 --- a/SmartDeviceLink/SDLSendLocation.m +++ b/SmartDeviceLink/SDLSendLocation.m @@ -28,15 +28,19 @@ } - (instancetype)initWithLongitude:(CGFloat)longitude latitude:(CGFloat)latitude locationName:(NSString *)locationName locationDescription:(NSString *)locationDescription address:(NSArray *)address phoneNumber:(NSString *)phoneNumber image:(SDLImage *)image { - if (self = [self init]) { - self.longitudeDegrees = @(longitude); - self.latitudeDegrees = @(latitude); - self.locationName = locationName; - self.locationDescription = locationDescription; - self.addressLines = address; - self.phoneNumber = phoneNumber; - self.locationImage = image; + self = [self init]; + if (!self) { + return nil; } + + self.longitudeDegrees = @(longitude); + self.latitudeDegrees = @(latitude); + self.locationName = locationName; + self.locationDescription = locationDescription; + self.addressLines = address; + self.phoneNumber = phoneNumber; + self.locationImage = image; + return self; } diff --git a/SmartDeviceLink/SDLSetAppIcon.m b/SmartDeviceLink/SDLSetAppIcon.m index dcc5c6da1..a5eec4e4d 100644 --- a/SmartDeviceLink/SDLSetAppIcon.m +++ b/SmartDeviceLink/SDLSetAppIcon.m @@ -21,9 +21,13 @@ } - (instancetype)initWithFileName:(NSString *)fileName { - if (self = [self init]) { - self.syncFileName = fileName; + self = [self init]; + if (!self) { + return nil; } + + self.syncFileName = fileName; + return self; } diff --git a/SmartDeviceLink/SDLSetDisplayLayout.m b/SmartDeviceLink/SDLSetDisplayLayout.m index d6b835b9f..2a1e0d0a3 100644 --- a/SmartDeviceLink/SDLSetDisplayLayout.m +++ b/SmartDeviceLink/SDLSetDisplayLayout.m @@ -22,15 +22,17 @@ } - (instancetype)initWithPredefinedLayout:(SDLPredefinedLayout *)predefinedLayout { - if (self = [self initWithLayout:predefinedLayout.value]) { - } - return self; + return [self initWithLayout:predefinedLayout.value]; } - (instancetype)initWithLayout:(NSString *)displayLayout { - if (self = [self init]) { - self.displayLayout = displayLayout; + self = [self init]; + if (!self) { + return nil; } + + self.displayLayout = displayLayout; + return self; } diff --git a/SmartDeviceLink/SDLSetGlobalProperties.m b/SmartDeviceLink/SDLSetGlobalProperties.m index 1a3912302..33f3c4f75 100644 --- a/SmartDeviceLink/SDLSetGlobalProperties.m +++ b/SmartDeviceLink/SDLSetGlobalProperties.m @@ -27,18 +27,20 @@ } - (instancetype)initWithHelpText:(NSString *)helpText timeoutText:(NSString *)timeoutText { - if (self = [self initWithHelpText:helpText timeoutText:timeoutText vrHelpTitle:nil vrHelp:nil]) { - } - return self; + return [self initWithHelpText:helpText timeoutText:timeoutText vrHelpTitle:nil vrHelp:nil]; } - (instancetype)initWithHelpText:(NSString *)helpText timeoutText:(NSString *)timeoutText vrHelpTitle:(NSString *)vrHelpTitle vrHelp:(NSArray *)vrHelp { - if (self = [self init]) { - self.helpPrompt = [SDLTTSChunkFactory buildTTSChunksFromSimple:helpText]; - self.timeoutPrompt = [SDLTTSChunkFactory buildTTSChunksFromSimple:timeoutText]; - self.vrHelpTitle = vrHelpTitle; - self.vrHelp = [vrHelp mutableCopy]; - } + self = [self init]; + if (!self) { + return nil; + } + + self.helpPrompt = [SDLTTSChunkFactory buildTTSChunksFromSimple:helpText]; + self.timeoutPrompt = [SDLTTSChunkFactory buildTTSChunksFromSimple:timeoutText]; + self.vrHelpTitle = vrHelpTitle; + self.vrHelp = [vrHelp mutableCopy]; + return self; } diff --git a/SmartDeviceLink/SDLSetMediaClockTimer.m b/SmartDeviceLink/SDLSetMediaClockTimer.m index e28388335..7f17ad17d 100644 --- a/SmartDeviceLink/SDLSetMediaClockTimer.m +++ b/SmartDeviceLink/SDLSetMediaClockTimer.m @@ -25,16 +25,24 @@ - (instancetype)initWithHours:(NSInteger)hours minutes:(NSInteger)minutes seconds:(NSInteger)seconds updateMode:(SDLUpdateMode *)updateMode { - if (self = [self initWithUpdateMode:updateMode]) { - self.startTime = [[SDLStartTime alloc] initWithHours:hours minutes:minutes seconds:seconds]; + self = [self initWithUpdateMode:updateMode]; + if (!self) { + return nil; } + + self.startTime = [[SDLStartTime alloc] initWithHours:hours minutes:minutes seconds:seconds]; + return self; } - (instancetype)initWithUpdateMode:(SDLUpdateMode *)updateMode { - if (self = [self init]) { - self.updateMode = updateMode; + self = [self init]; + if (!self) { + return nil; } + + self.updateMode = updateMode; + return self; } diff --git a/SmartDeviceLink/SDLShow.m b/SmartDeviceLink/SDLShow.m index 6448e7065..111e1fad1 100644 --- a/SmartDeviceLink/SDLShow.m +++ b/SmartDeviceLink/SDLShow.m @@ -25,31 +25,31 @@ } - (instancetype)initWithMainField1:(NSString *)mainField1 mainField2:(NSString *)mainField2 alignment:(SDLTextAlignment *)alignment { - if (self = [self initWithMainField1:mainField1 mainField2:mainField2 statusBar:nil mediaClock:nil mediaTrack:nil alignment:alignment]) { - } - return self; + return [self initWithMainField1:mainField1 mainField2:mainField2 statusBar:nil mediaClock:nil mediaTrack:nil alignment:alignment]; } - (instancetype)initWithMainField1:(NSString *)mainField1 mainField2:(NSString *)mainField2 statusBar:(NSString *)statusBar mediaClock:(NSString *)mediaClock mediaTrack:(NSString *)mediaTrack alignment:(SDLTextAlignment *)Alignment { - if (self = [self initWithMainField1:mainField1 mainField2:mainField2 mainField3:nil mainField4:nil statusBar:statusBar mediaClock:mediaClock mediaTrack:mediaTrack alignment:Alignment graphic:nil softButtons:nil customPresets:nil]) { - } - return self; + return [self initWithMainField1:mainField1 mainField2:mainField2 mainField3:nil mainField4:nil statusBar:statusBar mediaClock:mediaClock mediaTrack:mediaTrack alignment:Alignment graphic:nil softButtons:nil customPresets:nil]; } - (instancetype)initWithMainField1:(NSString *)mainField1 mainField2:(NSString *)mainField2 mainField3:(NSString *)mainField3 mainField4:(NSString *)mainField4 statusBar:(NSString *)statusBar mediaClock:(NSString *)mediaClock mediaTrack:(NSString *)mediaTrack alignment:(SDLTextAlignment *)alignment graphic:(SDLImage *)graphic softButtons:(NSArray *)softButtons customPresets:(NSArray *)customPresets { - if (self = [self init]) { - self.mainField1 = mainField1; - self.mainField2 = mainField2; - self.mainField3 = mainField3; - self.mainField4 = mainField4; - self.statusBar = statusBar; - self.mediaClock = mediaClock; - self.mediaTrack = mediaTrack; - self.alignment = alignment; - self.graphic = graphic; - self.softButtons = [softButtons mutableCopy]; - self.customPresets = [customPresets mutableCopy]; - } + self = [self init]; + if (!self) { + return nil; + } + + self.mainField1 = mainField1; + self.mainField2 = mainField2; + self.mainField3 = mainField3; + self.mainField4 = mainField4; + self.statusBar = statusBar; + self.mediaClock = mediaClock; + self.mediaTrack = mediaTrack; + self.alignment = alignment; + self.graphic = graphic; + self.softButtons = [softButtons mutableCopy]; + self.customPresets = [customPresets mutableCopy]; + return self; } diff --git a/SmartDeviceLink/SDLShowConstantTBT.m b/SmartDeviceLink/SDLShowConstantTBT.m index 175895c66..69987c86a 100644 --- a/SmartDeviceLink/SDLShowConstantTBT.m +++ b/SmartDeviceLink/SDLShowConstantTBT.m @@ -24,19 +24,23 @@ } - (instancetype)initWithNavigationText1:(NSString *)navigationText1 navigationText2:(NSString *)navigationText2 eta:(NSString *)eta timeToDestination:(NSString *)timeToDestination totalDistance:(NSString *)totalDistance turnIcon:(SDLImage *)turnIcon nextTurnIcon:(SDLImage *)nextTurnIcon distanceToManeuver:(NSNumber *)distanceToManeuver distanceToManeuverScale:(NSNumber *)distanceToManeuverScale maneuverComplete:(BOOL)maneuverComplete softButtons:(NSArray *)softButtons { - if (self = [self init]) { - self.navigationText1 = navigationText1; - self.navigationText2 = navigationText2; - self.eta = eta; - self.timeToDestination = timeToDestination; - self.totalDistance = totalDistance; - self.turnIcon = turnIcon; - self.nextTurnIcon = nextTurnIcon; - self.distanceToManeuver = distanceToManeuver; - self.distanceToManeuverScale = self.distanceToManeuverScale; - self.maneuverComplete = @(maneuverComplete); - self.softButtons = [softButtons mutableCopy]; - } + self = [self init]; + if (!self) { + return nil; + } + + self.navigationText1 = navigationText1; + self.navigationText2 = navigationText2; + self.eta = eta; + self.timeToDestination = timeToDestination; + self.totalDistance = totalDistance; + self.turnIcon = turnIcon; + self.nextTurnIcon = nextTurnIcon; + self.distanceToManeuver = distanceToManeuver; + self.distanceToManeuverScale = self.distanceToManeuverScale; + self.maneuverComplete = @(maneuverComplete); + self.softButtons = [softButtons mutableCopy]; + return self; } diff --git a/SmartDeviceLink/SDLSlider.m b/SmartDeviceLink/SDLSlider.m index 50cb55e04..cd43238a2 100644 --- a/SmartDeviceLink/SDLSlider.m +++ b/SmartDeviceLink/SDLSlider.m @@ -21,7 +21,6 @@ } - (instancetype)initWithNumTicks:(NSNumber *)numTicks position:(NSNumber *)position sliderHeader:(NSString *)sliderHeader sliderFooter:(NSString *)sliderFooter timeout:(NSNumber *)timeout { - NSMutableArray *sliderFooters = [NSMutableArray arrayWithCapacity:numTicks.unsignedIntegerValue]; // Populates array with the same footer value for each position @@ -29,19 +28,21 @@ sliderFooters[0] = sliderFooter; } - if (self = [self initWithNumTicks:numTicks position:position sliderHeader:sliderHeader sliderFooter:[sliderFooters copy] timeout:timeout]) { - } - return self; + return [self initWithNumTicks:numTicks position:position sliderHeader:sliderHeader sliderFooter:[sliderFooters copy] timeout:timeout]; } - (instancetype)initWithNumTicks:(NSNumber *)numTicks position:(NSNumber *)position sliderHeader:(NSString *)sliderHeader sliderFooters:(NSArray *)sliderFooters timeout:(NSNumber *)timeout { - if (self = [self init]) { - self.numTicks = numTicks; - self.position = position; - self.sliderHeader = sliderHeader; - self.sliderFooter = [sliderFooters mutableCopy]; - self.timeout = timeout; + self = [self init]; + if (!self) { + return nil; } + + self.numTicks = numTicks; + self.position = position; + self.sliderHeader = sliderHeader; + self.sliderFooter = [sliderFooters mutableCopy]; + self.timeout = timeout; + return self; } diff --git a/SmartDeviceLink/SDLSoftButton.m b/SmartDeviceLink/SDLSoftButton.m index 9f01b78bf..818047f8a 100644 --- a/SmartDeviceLink/SDLSoftButton.m +++ b/SmartDeviceLink/SDLSoftButton.m @@ -35,15 +35,19 @@ } - (instancetype)initWithType:(SDLSoftButtonType *)type text:(NSString *)text image:(SDLImage *)image highlighted:(BOOL)highlighted buttonId:(UInt16)buttonId systemAction:(SDLSystemAction *)systemAction handler:(SDLRPCNotificationHandler)handler { - if (self = [self init]) { - self.type = type; - self.text = text; - self.image = image; - self.isHighlighted = @(highlighted); - self.softButtonID = @(buttonId); - self.systemAction = systemAction; - self.handler = handler; + self = [self initWithHandler:handler]; + if (!self) { + return nil; } + + self.type = type; + self.text = text; + self.image = image; + self.isHighlighted = @(highlighted); + self.softButtonID = @(buttonId); + self.systemAction = systemAction; + self.handler = handler; + return self; } diff --git a/SmartDeviceLink/SDLSpeak.m b/SmartDeviceLink/SDLSpeak.m index f0b75aceb..60eaa1380 100644 --- a/SmartDeviceLink/SDLSpeak.m +++ b/SmartDeviceLink/SDLSpeak.m @@ -24,15 +24,17 @@ - (instancetype)initWithTTS:(NSString *)ttsText { NSMutableArray* ttsChunks = [SDLTTSChunkFactory buildTTSChunksFromSimple:ttsText]; - if (self = [self initWithTTSChunks:ttsChunks]) { - } - return self; + return [self initWithTTSChunks:ttsChunks]; } - (instancetype)initWithTTSChunks:(NSArray *)ttsChunks { - if (self = [self init]) { - self.ttsChunks = [ttsChunks mutableCopy]; + self = [self init]; + if (!self) { + return nil; } + + self.ttsChunks = [ttsChunks mutableCopy]; + return self; } diff --git a/SmartDeviceLink/SDLStartTime.m b/SmartDeviceLink/SDLStartTime.m index d17575ff5..2ee6e3a03 100644 --- a/SmartDeviceLink/SDLStartTime.m +++ b/SmartDeviceLink/SDLStartTime.m @@ -21,11 +21,15 @@ } - (instancetype)initWithHours:(NSInteger)hours minutes:(NSInteger)minutes seconds:(NSInteger)seconds { - if (self = [super init]) { - self.hours = @(hours); - self.minutes = @(minutes); - self.seconds = @(seconds); + self = [self init]; + if (!self) { + return nil; } + + self.hours = @(hours); + self.minutes = @(minutes); + self.seconds = @(seconds); + return self; } diff --git a/SmartDeviceLink/SDLSubscribeButton.m b/SmartDeviceLink/SDLSubscribeButton.m index a90508fb6..69290eaa4 100644 --- a/SmartDeviceLink/SDLSubscribeButton.m +++ b/SmartDeviceLink/SDLSubscribeButton.m @@ -34,10 +34,14 @@ } - (instancetype)initWithButtonName:(SDLButtonName *)buttonName handler:(SDLRPCNotificationHandler)handler { - if (self = [self init]) { - self.buttonName = buttonName; - self.handler = handler; + self = [self init]; + if (!self) { + return nil; } + + self.buttonName = buttonName; + self.handler = handler; + return self; } diff --git a/SmartDeviceLink/SDLSubscribeVehicleData.m b/SmartDeviceLink/SDLSubscribeVehicleData.m index d12a68049..c9938a09d 100644 --- a/SmartDeviceLink/SDLSubscribeVehicleData.m +++ b/SmartDeviceLink/SDLSubscribeVehicleData.m @@ -21,32 +21,36 @@ } - (instancetype)initWithAccelerationPedalPosition:(BOOL)accelerationPedalPosition airbagStatus:(BOOL)airbagStatus beltStatus:(BOOL)beltStatus bodyInformation:(BOOL)bodyInformation clusterModeStatus:(BOOL)clusterModeStatus deviceStatus:(BOOL)deviceStatus driverBraking:(BOOL)driverBraking eCallInfo:(BOOL)eCallInfo emergencyEvent:(BOOL)emergencyEvent engineTorque:(BOOL)engineTorque externalTemperature:(BOOL)externalTemperature fuelLevel:(BOOL)fuelLevel fuelLevelState:(BOOL)fuelLevelState gps:(BOOL)gps headLampStatus:(BOOL)headLampStatus instantFuelConsumption:(BOOL)instantFuelConsumption myKey:(BOOL)myKey odometer:(BOOL)odometer prndl:(BOOL)prndl rpm:(BOOL)rpm speed:(BOOL)speed steeringWheelAngle:(BOOL)steeringWheelAngle tirePressure:(BOOL)tirePressure wiperStatus:(BOOL)wiperStatus { - if (self = [self init]) { - self.accPedalPosition = @(accelerationPedalPosition); - self.airbagStatus = @(airbagStatus); - self.beltStatus = @(beltStatus); - self.bodyInformation = @(bodyInformation); - self.clusterModeStatus = @(clusterModeStatus); - self.deviceStatus = @(deviceStatus); - self.driverBraking = @(driverBraking); - self.eCallInfo = @(eCallInfo); - self.emergencyEvent = @(emergencyEvent); - self.engineTorque = @(engineTorque); - self.externalTemperature = @(externalTemperature); - self.fuelLevel = @(fuelLevel); - self.fuelLevel_State = @(fuelLevelState); - self.myKey = @(myKey); - self.odometer = @(odometer); - self.gps = @(gps); - self.headLampStatus = @(headLampStatus); - self.instantFuelConsumption = @(instantFuelConsumption); - self.prndl = @(prndl); - self.rpm = @(rpm); - self.speed = @(speed); - self.steeringWheelAngle = @(steeringWheelAngle); - self.tirePressure = @(tirePressure); - self.wiperStatus = @(wiperStatus); + self = [self init]; + if (!self) { + return nil; } + + self.accPedalPosition = @(accelerationPedalPosition); + self.airbagStatus = @(airbagStatus); + self.beltStatus = @(beltStatus); + self.bodyInformation = @(bodyInformation); + self.clusterModeStatus = @(clusterModeStatus); + self.deviceStatus = @(deviceStatus); + self.driverBraking = @(driverBraking); + self.eCallInfo = @(eCallInfo); + self.emergencyEvent = @(emergencyEvent); + self.engineTorque = @(engineTorque); + self.externalTemperature = @(externalTemperature); + self.fuelLevel = @(fuelLevel); + self.fuelLevel_State = @(fuelLevelState); + self.myKey = @(myKey); + self.odometer = @(odometer); + self.gps = @(gps); + self.headLampStatus = @(headLampStatus); + self.instantFuelConsumption = @(instantFuelConsumption); + self.prndl = @(prndl); + self.rpm = @(rpm); + self.speed = @(speed); + self.steeringWheelAngle = @(steeringWheelAngle); + self.tirePressure = @(tirePressure); + self.wiperStatus = @(wiperStatus); + return self; } diff --git a/SmartDeviceLink/SDLSyncMsgVersion.m b/SmartDeviceLink/SDLSyncMsgVersion.m index 8b3e3c8a2..4de144bd4 100644 --- a/SmartDeviceLink/SDLSyncMsgVersion.m +++ b/SmartDeviceLink/SDLSyncMsgVersion.m @@ -21,10 +21,14 @@ } - (instancetype)initWithMajorVersion:(NSInteger)majorVersion minorVersion:(NSInteger)minorVersion { - if (self = [self init]) { - self.majorVersion = @(majorVersion); - self.minorVersion = @(minorVersion); + self = [self init]; + if (!self) { + return nil; } + + self.majorVersion = @(majorVersion); + self.minorVersion = @(minorVersion); + return self; } diff --git a/SmartDeviceLink/SDLSystemRequest.m b/SmartDeviceLink/SDLSystemRequest.m index 6ac5fa92e..5deaff059 100644 --- a/SmartDeviceLink/SDLSystemRequest.m +++ b/SmartDeviceLink/SDLSystemRequest.m @@ -23,10 +23,14 @@ } - (instancetype)initWithType:(SDLRequestType *)requestType fileName:(NSString *)fileName { - if (self = [self init]) { - self.requestType = requestType; - self.fileName = fileName; + self = [self init]; + if (!self) { + return nil; } + + self.requestType = requestType; + self.fileName = fileName; + return self; } diff --git a/SmartDeviceLink/SDLTurn.h b/SmartDeviceLink/SDLTurn.h index ef2cf9ebe..5c9b155a5 100644 --- a/SmartDeviceLink/SDLTurn.h +++ b/SmartDeviceLink/SDLTurn.h @@ -12,6 +12,8 @@ - (instancetype)init; - (instancetype)initWithDictionary:(NSMutableDictionary *)dict; +- (instancetype)initWithNavigationText:(NSString*)navigationText turnIcon:(SDLImage*)icon; + @property (strong) NSString *navigationText; @property (strong) SDLImage *turnIcon; diff --git a/SmartDeviceLink/SDLTurn.m b/SmartDeviceLink/SDLTurn.m index 875fa2e73..2e753c8be 100644 --- a/SmartDeviceLink/SDLTurn.m +++ b/SmartDeviceLink/SDLTurn.m @@ -21,6 +21,18 @@ return self; } +- (instancetype)initWithNavigationText:(NSString*)navigationText turnIcon:(SDLImage*)icon { + self = [self init]; + if (!self) { + return nil; + } + + self.navigationText = navigationText; + self.turnIcon = icon; + + return self; +} + - (void)setNavigationText:(NSString *)navigationText { if (navigationText != nil) { [store setObject:navigationText forKey:NAMES_navigationText]; diff --git a/SmartDeviceLink/SDLUnsubscribeButton.m b/SmartDeviceLink/SDLUnsubscribeButton.m index c4f05c23f..90df09b24 100644 --- a/SmartDeviceLink/SDLUnsubscribeButton.m +++ b/SmartDeviceLink/SDLUnsubscribeButton.m @@ -23,9 +23,13 @@ } - (instancetype)initWithButtonName:(SDLButtonName *)buttonName { - if (self = [self init]) { - self.buttonName = buttonName; + self = [self init]; + if (!self) { + return nil; } + + self.buttonName = buttonName; + return self; } diff --git a/SmartDeviceLink/SDLUnsubscribeVehicleData.m b/SmartDeviceLink/SDLUnsubscribeVehicleData.m index 20b9ce913..5771808fb 100644 --- a/SmartDeviceLink/SDLUnsubscribeVehicleData.m +++ b/SmartDeviceLink/SDLUnsubscribeVehicleData.m @@ -21,32 +21,36 @@ } - (instancetype)initWithAccelerationPedalPosition:(BOOL)accelerationPedalPosition airbagStatus:(BOOL)airbagStatus beltStatus:(BOOL)beltStatus bodyInformation:(BOOL)bodyInformation clusterModeStatus:(BOOL)clusterModeStatus deviceStatus:(BOOL)deviceStatus driverBraking:(BOOL)driverBraking eCallInfo:(BOOL)eCallInfo emergencyEvent:(BOOL)emergencyEvent engineTorque:(BOOL)engineTorque externalTemperature:(BOOL)externalTemperature fuelLevel:(BOOL)fuelLevel fuelLevelState:(BOOL)fuelLevelState gps:(BOOL)gps headLampStatus:(BOOL)headLampStatus instantFuelConsumption:(BOOL)instantFuelConsumption myKey:(BOOL)myKey odometer:(BOOL)odometer prndl:(BOOL)prndl rpm:(BOOL)rpm speed:(BOOL)speed steeringWheelAngle:(BOOL)steeringWheelAngle tirePressure:(BOOL)tirePressure wiperStatus:(BOOL)wiperStatus { - if (self = [self init]) { - self.accPedalPosition = @(accelerationPedalPosition); - self.airbagStatus = @(airbagStatus); - self.beltStatus = @(beltStatus); - self.bodyInformation = @(bodyInformation); - self.clusterModeStatus = @(clusterModeStatus); - self.deviceStatus = @(deviceStatus); - self.driverBraking = @(driverBraking); - self.eCallInfo = @(eCallInfo); - self.emergencyEvent = @(emergencyEvent); - self.engineTorque = @(engineTorque); - self.externalTemperature = @(externalTemperature); - self.fuelLevel = @(fuelLevel); - self.fuelLevel_State = @(fuelLevelState); - self.myKey = @(myKey); - self.odometer = @(odometer); - self.gps = @(gps); - self.headLampStatus = @(headLampStatus); - self.instantFuelConsumption = @(instantFuelConsumption); - self.prndl = @(prndl); - self.rpm = @(rpm); - self.speed = @(speed); - self.steeringWheelAngle = @(steeringWheelAngle); - self.tirePressure = @(tirePressure); - self.wiperStatus = @(wiperStatus); + self = [self init]; + if (!self) { + return nil; } + + self.accPedalPosition = @(accelerationPedalPosition); + self.airbagStatus = @(airbagStatus); + self.beltStatus = @(beltStatus); + self.bodyInformation = @(bodyInformation); + self.clusterModeStatus = @(clusterModeStatus); + self.deviceStatus = @(deviceStatus); + self.driverBraking = @(driverBraking); + self.eCallInfo = @(eCallInfo); + self.emergencyEvent = @(emergencyEvent); + self.engineTorque = @(engineTorque); + self.externalTemperature = @(externalTemperature); + self.fuelLevel = @(fuelLevel); + self.fuelLevel_State = @(fuelLevelState); + self.myKey = @(myKey); + self.odometer = @(odometer); + self.gps = @(gps); + self.headLampStatus = @(headLampStatus); + self.instantFuelConsumption = @(instantFuelConsumption); + self.prndl = @(prndl); + self.rpm = @(rpm); + self.speed = @(speed); + self.steeringWheelAngle = @(steeringWheelAngle); + self.tirePressure = @(tirePressure); + self.wiperStatus = @(wiperStatus); + return self; } diff --git a/SmartDeviceLink/SDLUpdateTurnList.m b/SmartDeviceLink/SDLUpdateTurnList.m index 54d0d9555..f615faa81 100644 --- a/SmartDeviceLink/SDLUpdateTurnList.m +++ b/SmartDeviceLink/SDLUpdateTurnList.m @@ -23,10 +23,14 @@ } - (instancetype)initWithTurnList:(NSArray *)turnList softButtons:(NSArray *)softButtons { - if (self = [self init]) { - self.turnList = [turnList mutableCopy]; - self.softButtons = [softButtons mutableCopy]; + self = [self init]; + if (!self) { + return nil; } + + self.turnList = [turnList mutableCopy]; + self.softButtons = [softButtons mutableCopy]; + return self; } diff --git a/SmartDeviceLink/SDLVrHelpItem.h b/SmartDeviceLink/SDLVrHelpItem.h index a46c1301b..cbb596a7c 100644 --- a/SmartDeviceLink/SDLVrHelpItem.h +++ b/SmartDeviceLink/SDLVrHelpItem.h @@ -12,6 +12,8 @@ - (instancetype)init; - (instancetype)initWithDictionary:(NSMutableDictionary *)dict; +- (instancetype)initWithText:(NSString*)text image:(SDLImage*)image position:(NSNumber*)position; + @property (strong) NSString *text; @property (strong) SDLImage *image; @property (strong) NSNumber *position; diff --git a/SmartDeviceLink/SDLVrHelpItem.m b/SmartDeviceLink/SDLVrHelpItem.m index 4ed2c1409..7e79b47da 100644 --- a/SmartDeviceLink/SDLVrHelpItem.m +++ b/SmartDeviceLink/SDLVrHelpItem.m @@ -21,6 +21,19 @@ return self; } +- (instancetype)initWithText:(NSString*)text image:(SDLImage*)image position:(NSNumber*)position { + self = [self init]; + if (!self) { + return nil; + } + + self.text = text; + self.image = image; + self.position = position; + + return self; +} + - (void)setText:(NSString *)text { if (text != nil) { [store setObject:text forKey:NAMES_text]; |