File tree Expand file tree Collapse file tree 9 files changed +61
-9
lines changed Expand file tree Collapse file tree 9 files changed +61
-9
lines changed Original file line number Diff line number Diff line change 2
2
// Group.h
3
3
// MyApp
4
4
//
5
- // Generated by Ian Terrell on 03/22 /2009.
5
+ // Generated by Ian Terrell on 04/12 /2009.
6
6
// Copyright 2009 Ian Terrell. All rights reserved.
7
7
//
8
8
23
23
24
24
+(NSString *)helloWorld ;
25
25
26
+ +(void )deleteAll ;
27
+
26
28
@end
Original file line number Diff line number Diff line change 2
2
// Group.m
3
3
// MyApp
4
4
//
5
- // Generated by Ian Terrell on 03/22 /2009.
5
+ // Generated by Ian Terrell on 04/12 /2009.
6
6
// Copyright 2009 Ian Terrell. All rights reserved.
7
7
//
8
8
9
9
#import " Group.h"
10
+ #import " SQLiteInstanceManager.h"
10
11
11
12
@implementation Group
12
13
@@ -23,6 +24,15 @@ +(NSString *)helloWorld {
23
24
24
25
}
25
26
27
+ +(void )deleteAll {
28
+ NSString *sql = [NSString stringWithFormat: @" DELETE FROM %@ ;" , [Group tableName ]];
29
+ NSLog ([NSString stringWithFormat: @" Executing SQL: DELETE FROM %@ ;" , [Group tableName ]]);
30
+ SQLiteInstanceManager *manager = [SQLiteInstanceManager sharedManager ];
31
+ [manager executeUpdateSQL: sql];
32
+ [manager vacuum ];
33
+ [Group clearCache ];
34
+ }
35
+
26
36
- (void )dealloc
27
37
{
28
38
[title release ];
Original file line number Diff line number Diff line change 2
2
// Preferences.h
3
3
// MyApp
4
4
//
5
- // Generated by Ian Terrell on 03/22 /2009
5
+ // Generated by Ian Terrell on 04/12 /2009
6
6
// Copyright 2009 Ian Terrell. All rights reserved.
7
7
//
8
8
Original file line number Diff line number Diff line change 2
2
// Preferences.m
3
3
// MyApp
4
4
//
5
- // Generated by Ian Terrell on 03/22 /2009
5
+ // Generated by Ian Terrell on 04/12 /2009
6
6
// Copyright 2009 Ian Terrell. All rights reserved.
7
7
//
8
8
9
9
#import " Preferences.h"
10
10
11
11
@implementation Preferences
12
12
13
+ NSString * _username;
14
+ NSString * _password;
15
+
13
16
+(BOOL )preferencesSet {
14
17
return !(
15
18
(([Preferences username ] == nil ) || ([[Preferences username ] isEqualToString: @" " ])) ||
@@ -19,14 +22,20 @@ +(BOOL)preferencesSet {
19
22
20
23
+(void )setUsername : (NSString *)username andPassword : (NSString *)password {
21
24
[[NSUserDefaults standardUserDefaults ] setObject: username forKey: @" username" ];
25
+ _username = username;
22
26
[[NSUserDefaults standardUserDefaults ] setObject: password forKey: @" password" ];
27
+ _password = password;
23
28
}
24
29
25
30
+(NSString *)username {
26
- return [[NSUserDefaults standardUserDefaults ] stringForKey: @" username" ];
31
+ if (_username == nil )
32
+ _username = [[NSUserDefaults standardUserDefaults ] stringForKey: @" username" ];
33
+ return _username;
27
34
}
28
35
+(NSString *)password {
29
- return [[NSUserDefaults standardUserDefaults ] stringForKey: @" password" ];
36
+ if (_password == nil )
37
+ _password = [[NSUserDefaults standardUserDefaults ] stringForKey: @" password" ];
38
+ return _password;
30
39
}
31
40
32
41
+(NSString *)helloWorld {
Original file line number Diff line number Diff line change 2
2
// User.h
3
3
// MyApp
4
4
//
5
- // Generated by Ian Terrell on 03/22 /2009.
5
+ // Generated by Ian Terrell on 04/12 /2009.
6
6
// Copyright 2009 Ian Terrell. All rights reserved.
7
7
//
8
8
@@ -31,4 +31,6 @@ typedef enum {
31
31
@property (nonatomic ,readwrite ,retain ) Group *anotherGroup;
32
32
33
33
34
+ +(void )deleteAll ;
35
+
34
36
@end
Original file line number Diff line number Diff line change 2
2
// User.m
3
3
// MyApp
4
4
//
5
- // Generated by Ian Terrell on 03/22 /2009.
5
+ // Generated by Ian Terrell on 04/12 /2009.
6
6
// Copyright 2009 Ian Terrell. All rights reserved.
7
7
//
8
8
9
9
#import " User.h"
10
+ #import " SQLiteInstanceManager.h"
10
11
11
12
@implementation User
12
13
@@ -21,6 +22,15 @@ @implementation User
21
22
)
22
23
23
24
25
+ +(void )deleteAll {
26
+ NSString *sql = [NSString stringWithFormat: @" DELETE FROM %@ ;" , [User tableName ]];
27
+ NSLog ([NSString stringWithFormat: @" Executing SQL: DELETE FROM %@ ;" , [User tableName ]]);
28
+ SQLiteInstanceManager *manager = [SQLiteInstanceManager sharedManager ];
29
+ [manager executeUpdateSQL: sql];
30
+ [manager vacuum ];
31
+ [User clearCache ];
32
+ }
33
+
24
34
- (void )dealloc
25
35
{
26
36
[username release ];
Original file line number Diff line number Diff line change 10
10
11
11
@implementation Preferences
12
12
13
+ <% object.fields.each do |field| -%>
14
+ <%= field[:type] %> _<%= field[:name] %>;
15
+ <% end -%>
16
+
13
17
+(BOOL )preferencesSet {
14
18
return !(
15
19
<%= object.fields .map {|field|object.is_set ?(field)}.join (" || \n " ) %>
@@ -20,13 +24,16 @@ +(BOOL)preferencesSet {
20
24
+(void )<%= object.bulk_setter_name_for(setter) %> {
21
25
<% setter.each do |field| -%>
22
26
[[NSUserDefaults standardUserDefaults ] <%= object.setter_for_key (field[:type])%>:<%= field[:name] %> forKey:@" <%= field[:name]%>" ];
27
+ _<%= field[:name] %> = <%= field[:name] %>;
23
28
<% end -%>
24
29
}
25
30
<% end -%>
26
31
27
32
<% object.fields.each do |field| -%>
28
33
+(<%= field[:type] %>)<%= field[:name] %> {
29
- return [[NSUserDefaults standardUserDefaults ] <%= object.type_for_key (field[:symbol_type])%>:@" <%= field[:name] %>" ];
34
+ if (_<%= field[:name] %> == nil )
35
+ _<%= field[:name] %> = [[NSUserDefaults standardUserDefaults ] <%= object.type_for_key (field[:symbol_type])%>:@" <%= field[:name] %>" ];
36
+ return _<%= field[:name] %>;
30
37
}
31
38
<% end -%>
32
39
Original file line number Diff line number Diff line change @@ -35,4 +35,6 @@ typedef enum {
35
35
<%= method[:signature] %>;
36
36
<% end -%>
37
37
38
+ +(void )deleteAll;
39
+
38
40
@end
Original file line number Diff line number Diff line change 7
7
//
8
8
9
9
#import " <%= object.name %>.h"
10
+ #import " SQLiteInstanceManager.h"
10
11
11
12
@implementation <%= object.name %>
12
13
@@ -24,6 +25,15 @@ @implementation <%= object.name %>
24
25
}
25
26
<% end -%>
26
27
28
+ +(void )deleteAll {
29
+ NSString *sql = [NSString stringWithFormat: @" DELETE FROM %@ ;" , [<%= object.name %> tableName]];
30
+ NSLog ([NSString stringWithFormat: @" Executing SQL: DELETE FROM %@ ;" , [<%= object.name %> tableName]]);
31
+ SQLiteInstanceManager *manager = [SQLiteInstanceManager sharedManager ];
32
+ [manager executeUpdateSQL: sql];
33
+ [manager vacuum ];
34
+ [<%= object.name %> clearCache];
35
+ }
36
+
27
37
- (void )dealloc
28
38
{
29
39
<% object.fields .select {|field|field[:type].ends_with ?(" *" )}.each do |field| -%>
You can’t perform that action at this time.
0 commit comments