From 62d852687c2b2ade8c9e9aa28d91ecc868e7f6df Mon Sep 17 00:00:00 2001 From: Tanner Bennett Date: Tue, 6 Aug 2019 17:29:17 -0500 Subject: [PATCH] More code style fixes --- .../FLEXTableListViewController.m | 4 +- .../FLEXSQLCommandExecutionViewController.h | 2 +- .../FLEXSQLCommandExecutionViewController.m | 81 ++++++++++--------- 3 files changed, 44 insertions(+), 43 deletions(-) diff --git a/Classes/GlobalStateExplorers/DatabaseBrowser/FLEXTableListViewController.m b/Classes/GlobalStateExplorers/DatabaseBrowser/FLEXTableListViewController.m index eafe44dea9..5a847ee283 100644 --- a/Classes/GlobalStateExplorers/DatabaseBrowser/FLEXTableListViewController.m +++ b/Classes/GlobalStateExplorers/DatabaseBrowser/FLEXTableListViewController.m @@ -76,7 +76,7 @@ - (IBAction)actionSelected { handler: ^(UIAlertAction *action) { FLEXSQLCommandExecutionViewController* controller = [FLEXSQLCommandExecutionViewController new]; controller.dbManager = dbManager; - controller.isSelectionType = false; + controller.isSelect = NO; [self.navigationController pushViewController:controller animated: true]; } @@ -88,7 +88,7 @@ - (IBAction)actionSelected { handler: ^(UIAlertAction *action) { FLEXSQLCommandExecutionViewController* controller = [FLEXSQLCommandExecutionViewController new]; controller.dbManager = dbManager; - controller.isSelectionType = true; + controller.isSelect = YES; [self.navigationController pushViewController:controller animated: true]; } diff --git a/Classes/GlobalStateExplorers/SQLExecutionControllers/FLEXSQLCommandExecutionViewController.h b/Classes/GlobalStateExplorers/SQLExecutionControllers/FLEXSQLCommandExecutionViewController.h index e292064e67..6bfae8db5d 100644 --- a/Classes/GlobalStateExplorers/SQLExecutionControllers/FLEXSQLCommandExecutionViewController.h +++ b/Classes/GlobalStateExplorers/SQLExecutionControllers/FLEXSQLCommandExecutionViewController.h @@ -10,6 +10,6 @@ #import "FLEXSQLiteDatabaseManager.h" @interface FLEXSQLCommandExecutionViewController: UIViewController -@property (nonatomic) BOOL isSelectionType; +@property (nonatomic) BOOL isSelect; @property (nonatomic) FLEXSQLiteDatabaseManager *dbManager; @end diff --git a/Classes/GlobalStateExplorers/SQLExecutionControllers/FLEXSQLCommandExecutionViewController.m b/Classes/GlobalStateExplorers/SQLExecutionControllers/FLEXSQLCommandExecutionViewController.m index 750f9d2491..435a6cddfb 100644 --- a/Classes/GlobalStateExplorers/SQLExecutionControllers/FLEXSQLCommandExecutionViewController.m +++ b/Classes/GlobalStateExplorers/SQLExecutionControllers/FLEXSQLCommandExecutionViewController.m @@ -21,12 +21,11 @@ @interface FLEXSQLCommandExecutionViewController () @end @implementation FLEXSQLCommandExecutionViewController -@synthesize isSelectionType, dbManager, textView, submitButton, statusLabel; - (void)viewDidLoad { [super viewDidLoad]; - self.navigationItem.title = isSelectionType ? @"Select with SQL" : @"Execute SQL"; + self.navigationItem.title = self.isSelect ? @"Select with SQL" : @"Execute SQL"; [self.view addObserver:self forKeyPath:@"frame" options:0 context:NULL]; [self addOtherUIElementsAndPositionThem]; @@ -37,32 +36,32 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N } - (void)addOtherUIElementsAndPositionThem { - if(textView == nil) { - textView = [UITextView new]; - textView.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1.0]; - textView.textColor = [UIColor blackColor]; + if (!self.textView) { + self.textView = [UITextView new]; + self.textView.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1.0]; + self.textView.textColor = [UIColor blackColor]; - [self.view addSubview:textView]; + [self.view addSubview:self.textView]; } - if(submitButton == nil) { - submitButton = [UIButton new]; + if (!self.submitButton) { + self.submitButton = [UIButton new]; - [submitButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; - [submitButton setBackgroundColor:[UIColor colorWithWhite:0.9 alpha:1.0]]; + [self.submitButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; + [self.submitButton setBackgroundColor:[UIColor colorWithWhite:0.9 alpha:1.0]]; - [submitButton setTitle:@"Submit" forState:UIControlStateNormal]; - [submitButton addTarget:self action:@selector(submitPressed) forControlEvents:UIControlEventTouchUpInside]; + [self.submitButton setTitle:@"Submit" forState:UIControlStateNormal]; + [self.submitButton addTarget:self action:@selector(submitPressed) forControlEvents:UIControlEventTouchUpInside]; - [self.view addSubview:submitButton]; + [self.view addSubview:self.submitButton]; } - if(statusLabel == nil) { - statusLabel = [UILabel new]; + if (!self.statusLabel) { + self.statusLabel = [UILabel new]; - statusLabel.textAlignment = NSTextAlignmentCenter; - statusLabel.textColor = [UIColor blackColor]; - [self.view addSubview:statusLabel]; + self.statusLabel.textAlignment = NSTextAlignmentCenter; + self.statusLabel.textColor = [UIColor blackColor]; + [self.view addSubview:self.statusLabel]; } self.view.backgroundColor = [UIColor whiteColor]; @@ -74,19 +73,20 @@ - (void)addOtherUIElementsAndPositionThem { CGFloat statusLabelHeight = 70; CGFloat textViewHeight = self.view.frame.size.height - startingY - submitButtonHeight - statusLabelHeight - sideMargin * 4; - textView.frame = CGRectMake(sideMargin, startingY + sideMargin, width, textViewHeight); - statusLabel.frame = CGRectMake(sideMargin, textView.frame.origin.y + textViewHeight + sideMargin, width, statusLabelHeight); - submitButton.frame = CGRectMake(sideMargin, statusLabel.frame.origin.y + statusLabelHeight + sideMargin, width, submitButtonHeight); + self.textView.frame = CGRectMake(sideMargin, startingY + sideMargin, width, textViewHeight); + self.statusLabel.frame = CGRectMake(sideMargin, self.textView.frame.origin.y + textViewHeight + sideMargin, width, statusLabelHeight); + self.submitButton.frame = CGRectMake(sideMargin, self.statusLabel.frame.origin.y + statusLabelHeight + sideMargin, width, submitButtonHeight); } -- (void)submitPressed { - NSString* text = textView.text == nil ? @"" : textView.text; +- (void)submitPressed +{ + NSString *text = self.textView.text == nil ? @"" : self.textView.text; - if (isSelectionType) { + if (self.isSelect) { NSString *errorString; - NSArray *> *responce = [dbManager executeSelectionQuery:text error:&errorString]; + NSArray *> *response = [self.dbManager executeSelectionQuery:text error:&errorString]; - if (responce == nil) { + if (!response) { [self presentOnErrorAlert:errorString]; return; } @@ -103,31 +103,32 @@ - (void)submitPressed { FLEXTableContentViewController *contentViewController = [FLEXTableContentViewController new]; - contentViewController.contentsArray = responce; - contentViewController.columnsArray = [tables copy]; + contentViewController.contentsArray = response; + contentViewController.columnsArray = tables; - contentViewController.title = @"Executed sql"; + contentViewController.title = @"Executed SQL"; [self.navigationController pushViewController:contentViewController animated:YES]; } else { - NSString* errorMessage = [self.dbManager executeNonSelectQuery:text]; - - statusLabel.text = errorMessage == nil ? @"SUCCESS" : errorMessage; + NSString *errorMessage = [self.dbManager executeNonSelectQuery:text]; + self.statusLabel.text = errorMessage ?: @"SUCCESS"; } } -- (void)presentOnErrorAlert: (NSString *)message +- (void)presentOnErrorAlert:(NSString *)message { UIAlertController *alert = [UIAlertController - alertControllerWithTitle:@"SQL Execution error !!!" - message:message - preferredStyle:UIAlertControllerStyleAlert]; + alertControllerWithTitle:@"SQL Execution error !!!" + message:message + preferredStyle:UIAlertControllerStyleAlert + ]; UIAlertAction *okButton = [UIAlertAction - actionWithTitle:@"Ok" - style:UIAlertActionStyleDestructive - handler:nil]; + actionWithTitle:@"Ok" + style:UIAlertActionStyleDestructive + handler:nil + ]; [alert addAction:okButton]; [self presentViewController:alert animated:YES completion:nil];