forked from S1lv10Fr4gn4n1/examples-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewController.m
More file actions
98 lines (78 loc) · 2.79 KB
/
Copy pathViewController.m
File metadata and controls
98 lines (78 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//
// ViewController.m
// iBrowserSQLite
//
// Created by Silvio Fragnani da Silva on 20/03/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize textSQL;
@synthesize commandText;
@synthesize resultText;
- (void)viewDidLoad
{
[super viewDidLoad];
[commandText becomeFirstResponder];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[self setTextSQL:nil];
[self setCommandText:nil];
[self setResultText:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
- (IBAction)actionExecute:(id)sender
{
ManagerSQLiteSingleton * manager = [ManagerSQLiteSingleton instance];
// [manager executeQuery:@"insert into user (NAME,EMAIL,ACTIVE,PHOTO,USER_UPDATE,DATE_UPDATE,USER_INSERT,DATE_INSERT) values ('Silvio Fragnani da Silva', 'silviofragnanisilva@gmail.com', 1, null,1,current_date,1,current_date)" paramns: nil];
if ([[commandText text]isEqualToString:@""]) {
return;
}
const char* error = nil;
NSArray *resultSet = [manager executeQuery:[commandText text] paramns:nil error:&error];
NSMutableString *s = [[NSMutableString alloc]init];
for (NSDictionary *dicti in resultSet) {
[s appendFormat:@"%@",dicti];
}
if (error) {
NSMutableString *s = [[NSMutableString alloc]initWithFormat:@"%s", error];
[resultText setText:s];
} else if ([s isEqualToString:@""]) {
[resultText setText:@"no results"];
} else {
[resultText setText:s];
}
// http://www.binpress.com/app/ios-data-grid-table-view/586#features
// [stringCmdText setString: [cmdText text]];
//
// NSRange rangeStart = [stringCmdText rangeOfString:cursor options:NSBackwardsSearch];
// NSRange rangeEnd = [stringCmdText rangeOfString:@"\n" options:NSBackwardsSearch];
//
// if ((rangeEnd.location != NSNotFound) && ([stringCmdText length] == (rangeEnd.location +1))) {
// NSString * stringAux = [self getStringCommand:stringCmdText
// rangeStart:rangeStart
// rangeEnd: rangeEnd];
//
// SFSCommand * command = [self makeCommand:stringAux];
// NSString * strResult = [self executeCommand:command];
//
// [stringCmdText appendString:strResult];
// [stringCmdText appendString:cursor];
// [cmdText setText:stringCmdText];
// }
}
- (IBAction)actionClean:(id)sender
{
[commandText setText:NULL];
[resultText setText:NULL];
}
@end