@@ -21,12 +21,11 @@ @interface FLEXSQLCommandExecutionViewController ()
2121@end 
2222
2323@implementation  FLEXSQLCommandExecutionViewController 
24- @synthesize  isSelectionType, dbManager, textView, submitButton, statusLabel;
2524
2625- (void )viewDidLoad  {
2726    [super  viewDidLoad ];
2827
29-     self.navigationItem .title  = isSelectionType  ? @" Select with SQL" @" Execute SQL" 
28+     self.navigationItem .title  = self. isSelect  ? @" Select with SQL" @" Execute SQL" 
3029    [self .view addObserver: self  forKeyPath: @" frame" options: 0  context: NULL ];
3130
3231    [self  addOtherUIElementsAndPositionThem ];
@@ -37,32 +36,32 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
3736}
3837
3938- (void )addOtherUIElementsAndPositionThem  {
40-     if ( textView ==  nil ) {
41-         textView = [UITextView new ];
42-         textView.backgroundColor  = [UIColor colorWithWhite: 0.9  alpha: 1.0 ];
43-         textView.textColor  = [UIColor blackColor ];
39+     if  (!self. textView ) {
40+         self. textView  = [UITextView new ];
41+         self. textView .backgroundColor  = [UIColor colorWithWhite: 0.9  alpha: 1.0 ];
42+         self. textView .textColor  = [UIColor blackColor ];
4443
45-         [self .view addSubview: textView];
44+         [self .view addSubview: self . textView];
4645    }
4746
48-     if ( submitButton ==  nil ) {
49-         submitButton = [UIButton new ];
47+     if  (!self. submitButton ) {
48+         self. submitButton  = [UIButton new ];
5049
51-         [submitButton setTitleColor: [UIColor blueColor ] forState: UIControlStateNormal];
52-         [submitButton setBackgroundColor: [UIColor colorWithWhite: 0.9  alpha: 1.0 ]];
50+         [self . submitButton setTitleColor: [UIColor blueColor ] forState: UIControlStateNormal];
51+         [self . submitButton setBackgroundColor: [UIColor colorWithWhite: 0.9  alpha: 1.0 ]];
5352
54-         [submitButton setTitle: @" Submit" forState: UIControlStateNormal];
55-         [submitButton addTarget: self  action: @selector (submitPressed ) forControlEvents: UIControlEventTouchUpInside];
53+         [self . submitButton setTitle: @" Submit" forState: UIControlStateNormal];
54+         [self . submitButton addTarget: self  action: @selector (submitPressed ) forControlEvents: UIControlEventTouchUpInside];
5655
57-         [self .view addSubview: submitButton];
56+         [self .view addSubview: self . submitButton];
5857    }
5958
60-     if ( statusLabel ==  nil ) {
61-         statusLabel = [UILabel new ];
59+     if  (!self. statusLabel ) {
60+         self. statusLabel  = [UILabel new ];
6261
63-         statusLabel.textAlignment  = NSTextAlignmentCenter;
64-         statusLabel.textColor  = [UIColor blackColor ];
65-         [self .view addSubview: statusLabel];
62+         self. statusLabel .textAlignment  = NSTextAlignmentCenter;
63+         self. statusLabel .textColor  = [UIColor blackColor ];
64+         [self .view addSubview: self . statusLabel];
6665    }
6766
6867    self.view .backgroundColor  = [UIColor whiteColor ];
@@ -74,19 +73,20 @@ - (void)addOtherUIElementsAndPositionThem {
7473    CGFloat statusLabelHeight = 70 ;
7574    CGFloat textViewHeight = self.view .frame .size .height  - startingY - submitButtonHeight - statusLabelHeight - sideMargin * 4 ;
7675
77-     textView.frame  = CGRectMake (sideMargin, startingY + sideMargin, width, textViewHeight);
78-     statusLabel.frame  = CGRectMake (sideMargin, textView.frame .origin .y  + textViewHeight + sideMargin, width, statusLabelHeight);
79-     submitButton.frame  = CGRectMake (sideMargin, statusLabel.frame .origin .y  + statusLabelHeight + sideMargin, width, submitButtonHeight);
76+     self. textView .frame  = CGRectMake (sideMargin, startingY + sideMargin, width, textViewHeight);
77+     self. statusLabel .frame  = CGRectMake (sideMargin, self. textView .frame .origin .y  + textViewHeight + sideMargin, width, statusLabelHeight);
78+     self. submitButton .frame  = CGRectMake (sideMargin, self. statusLabel .frame .origin .y  + statusLabelHeight + sideMargin, width, submitButtonHeight);
8079}
8180
82- - (void )submitPressed  {
83-     NSString * text = textView.text  == nil  ? @" " text ;
81+ - (void )submitPressed 
82+ {
83+     NSString  *text = self.textView .text  == nil  ? @" " textView .text ;
8484
85-     if  (isSelectionType ) {
85+     if  (self. isSelect ) {
8686        NSString  *errorString;
87-         NSArray <NSDictionary <NSString  *, id > *> *responce  = [dbManager executeSelectionQuery: text error: &errorString];
87+         NSArray <NSDictionary <NSString  *, id > *> *response  = [self . dbManager executeSelectionQuery: text error: &errorString];
8888
89-         if  (responce ==  nil ) {
89+         if  (!response ) {
9090            [self  presentOnErrorAlert: errorString];
9191            return ;
9292        }
@@ -103,31 +103,32 @@ - (void)submitPressed {
103103
104104        FLEXTableContentViewController *contentViewController = [FLEXTableContentViewController new ];
105105
106-         contentViewController.contentsArray  = responce ;
107-         contentViewController.columnsArray  = [ tables  copy ] ;
106+         contentViewController.contentsArray  = response ;
107+         contentViewController.columnsArray  = tables;
108108
109-         contentViewController.title  = @" Executed sql " 
109+         contentViewController.title  = @" Executed SQL " 
110110
111111        [self .navigationController pushViewController: contentViewController animated: YES ];
112112    } else  {
113-         NSString * errorMessage = [self .dbManager executeNonSelectQuery: text];
114-         
115-         statusLabel.text  = errorMessage == nil  ? @" SUCCESS" 
113+         NSString  *errorMessage = [self .dbManager executeNonSelectQuery: text];
114+         self.statusLabel .text  = errorMessage ?: @" SUCCESS" 
116115    }
117116}
118117
119118
120- - (void )presentOnErrorAlert :   (NSString  *)message 
119+ - (void )presentOnErrorAlert : (NSString  *)message 
121120{
122121    UIAlertController *alert = [UIAlertController
123-                                  alertControllerWithTitle: @" SQL Execution error !!!" 
124-                                  message: message
125-                                  preferredStyle: UIAlertControllerStyleAlert];
122+         alertControllerWithTitle: @" SQL Execution error !!!" 
123+         message: message
124+         preferredStyle: UIAlertControllerStyleAlert
125+     ];
126126
127127    UIAlertAction *okButton = [UIAlertAction
128-                                actionWithTitle: @" Ok" 
129-                                style: UIAlertActionStyleDestructive
130-                                handler: nil ];
128+         actionWithTitle: @" Ok" 
129+         style: UIAlertActionStyleDestructive
130+         handler: nil 
131+     ];
131132
132133    [alert addAction: okButton];
133134    [self  presentViewController: alert animated: YES  completion: nil ];
0 commit comments