Skip to content

Commit 1dd969b

Browse files
committed
A bunch of fixes, updates and new functionality based on using SQLTable in multiple personal projects, Updated both the iOS and macOS examples to match the latest code
1 parent 977eb12 commit 1dd969b

File tree

18 files changed

+316
-234
lines changed

18 files changed

+316
-234
lines changed

Examples/OSX/Resources/data.db

0 Bytes
Binary file not shown.

Examples/OSX/SQLiteDB-OSX.xcodeproj/project.pbxproj

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
DD76985F19F62E4000F7C8A5 /* data.db in Resources */ = {isa = PBXBuildFile; fileRef = DD76985E19F62E4000F7C8A5 /* data.db */; };
1515
DD76986419F62E9500F7C8A5 /* SQLiteDB.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD76986219F62E9500F7C8A5 /* SQLiteDB.swift */; };
1616
DD76986519F62E9500F7C8A5 /* String-Extras.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD76986319F62E9500F7C8A5 /* String-Extras.swift */; };
17-
DD76986719F62EFD00F7C8A5 /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = DD76986619F62EFD00F7C8A5 /* libsqlite3.dylib */; };
17+
DD7FFDAF1D2360B5003EB06B /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = DD7FFDAE1D2360B5003EB06B /* libsqlite3.tbd */; };
18+
DD7FFDB31D2361A3003EB06B /* Category.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD7FFDB11D2361A3003EB06B /* Category.swift */; };
19+
DD7FFDB41D2361A3003EB06B /* Task.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD7FFDB21D2361A3003EB06B /* Task.swift */; };
20+
DD7FFDB61D236201003EB06B /* SQLTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD7FFDB51D236201003EB06B /* SQLTable.swift */; };
1821
/* End PBXBuildFile section */
1922

2023
/* Begin PBXFileReference section */
@@ -27,16 +30,19 @@
2730
DD76985E19F62E4000F7C8A5 /* data.db */ = {isa = PBXFileReference; lastKnownFileType = file; path = data.db; sourceTree = "<group>"; };
2831
DD76986219F62E9500F7C8A5 /* SQLiteDB.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SQLiteDB.swift; path = ../../SQLiteDB.swift; sourceTree = "<group>"; };
2932
DD76986319F62E9500F7C8A5 /* String-Extras.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "String-Extras.swift"; path = "../../String-Extras.swift"; sourceTree = "<group>"; };
30-
DD76986619F62EFD00F7C8A5 /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = usr/lib/libsqlite3.dylib; sourceTree = SDKROOT; };
3133
DD76986819F62F3E00F7C8A5 /* Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Bridging-Header.h"; sourceTree = "<group>"; };
34+
DD7FFDAE1D2360B5003EB06B /* libsqlite3.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.tbd; path = usr/lib/libsqlite3.tbd; sourceTree = SDKROOT; };
35+
DD7FFDB11D2361A3003EB06B /* Category.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Category.swift; sourceTree = "<group>"; };
36+
DD7FFDB21D2361A3003EB06B /* Task.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Task.swift; sourceTree = "<group>"; };
37+
DD7FFDB51D236201003EB06B /* SQLTable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SQLTable.swift; path = ../../SQLTable.swift; sourceTree = "<group>"; };
3238
/* End PBXFileReference section */
3339

3440
/* Begin PBXFrameworksBuildPhase section */
3541
DD76982C19F62D3000F7C8A5 /* Frameworks */ = {
3642
isa = PBXFrameworksBuildPhase;
3743
buildActionMask = 2147483647;
3844
files = (
39-
DD76986719F62EFD00F7C8A5 /* libsqlite3.dylib in Frameworks */,
45+
DD7FFDAF1D2360B5003EB06B /* libsqlite3.tbd in Frameworks */,
4046
);
4147
runOnlyForDeploymentPostprocessing = 0;
4248
};
@@ -46,7 +52,8 @@
4652
DD76982619F62D3000F7C8A5 = {
4753
isa = PBXGroup;
4854
children = (
49-
DD76986619F62EFD00F7C8A5 /* libsqlite3.dylib */,
55+
DD7FFDB01D2361A3003EB06B /* Shared */,
56+
DD7FFDAE1D2360B5003EB06B /* libsqlite3.tbd */,
5057
DD76985619F62DA100F7C8A5 /* Source */,
5158
DD76985119F62DA100F7C8A5 /* Resources */,
5259
DD76986019F62E5F00F7C8A5 /* Third-party */,
@@ -94,12 +101,23 @@
94101
DD76986119F62E6700F7C8A5 /* SQLiteDB */ = {
95102
isa = PBXGroup;
96103
children = (
104+
DD7FFDB51D236201003EB06B /* SQLTable.swift */,
97105
DD76986219F62E9500F7C8A5 /* SQLiteDB.swift */,
98106
DD76986319F62E9500F7C8A5 /* String-Extras.swift */,
99107
);
100108
name = SQLiteDB;
101109
sourceTree = "<group>";
102110
};
111+
DD7FFDB01D2361A3003EB06B /* Shared */ = {
112+
isa = PBXGroup;
113+
children = (
114+
DD7FFDB11D2361A3003EB06B /* Category.swift */,
115+
DD7FFDB21D2361A3003EB06B /* Task.swift */,
116+
);
117+
name = Shared;
118+
path = ../Shared;
119+
sourceTree = "<group>";
120+
};
103121
/* End PBXGroup section */
104122

105123
/* Begin PBXNativeTarget section */
@@ -173,8 +191,11 @@
173191
buildActionMask = 2147483647;
174192
files = (
175193
DD76986419F62E9500F7C8A5 /* SQLiteDB.swift in Sources */,
194+
DD7FFDB61D236201003EB06B /* SQLTable.swift in Sources */,
195+
DD7FFDB31D2361A3003EB06B /* Category.swift in Sources */,
176196
DD76986519F62E9500F7C8A5 /* String-Extras.swift in Sources */,
177197
DD76985D19F62DA200F7C8A5 /* ViewController.swift in Sources */,
198+
DD7FFDB41D2361A3003EB06B /* Task.swift in Sources */,
178199
DD76985C19F62DA200F7C8A5 /* AppDelegate.swift in Sources */,
179200
);
180201
runOnlyForDeploymentPostprocessing = 0;

Examples/OSX/Source/AppDelegate.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ import Cocoa
1010

1111
@NSApplicationMain
1212
class AppDelegate: NSObject, NSApplicationDelegate {
13-
let db = SQLiteDB.sharedInstance()
13+
let db = SQLiteDB.sharedInstance
1414

1515
func applicationDidFinishLaunching(notification: NSNotification) {
1616
// Insert code here to initialize your application
17+
let cats = Category.rows(order:"id ASC") as! [Category]
18+
NSLog("Got categories: \(cats)")
1719
}
1820

1921
func applicationWillTerminate(aNotification: NSNotification) {

Examples/Shared/Category.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
// Copyright © 2015 RookSoft Pte. Ltd. All rights reserved.
77
//
88

9-
import UIKit
9+
#if os(iOS)
10+
import UIKit
11+
#else
12+
import AppKit
13+
#endif
1014

1115
class Category:SQLTable {
1216
var id = -1
1317
var name = ""
1418

15-
init() {
16-
super.init(tableName:"categories")
17-
}
18-
19-
required convenience init(tableName:String) {
20-
self.init()
19+
override var description:String {
20+
return "id: \(id), name: \(name)"
2121
}
2222
}

Examples/Shared/Task.swift

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,14 @@
66
// Copyright © 2015 RookSoft Pte. Ltd. All rights reserved.
77
//
88

9-
import UIKit
9+
#if os(iOS)
10+
import UIKit
11+
#else
12+
import AppKit
13+
#endif
1014

1115
class Task:SQLTable {
1216
var id = -1
1317
var task = ""
1418
var categoryID = -1
15-
16-
init() {
17-
super.init(tableName:"tasks")
18-
}
19-
20-
required convenience init(tableName:String) {
21-
self.init()
22-
}
2319
}

Examples/iOS/Resources/data.db

0 Bytes
Binary file not shown.

Examples/iOS/SQLiteDB-iOS.xcodeproj/project.pbxproj

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
/* Begin PBXBuildFile section */
1010
DD04B4791BEC367E008E1261 /* SQLTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD04B4781BEC367E008E1261 /* SQLTable.swift */; };
1111
DD04B4811BEC511B008E1261 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DD04B47F1BEC511B008E1261 /* Launch Screen.storyboard */; };
12-
DD04B4851BEC6D6D008E1261 /* Category.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD04B4831BEC6D6D008E1261 /* Category.swift */; };
13-
DD04B4861BEC6D6D008E1261 /* Task.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD04B4841BEC6D6D008E1261 /* Task.swift */; };
1412
DD18184219D56B5B0053E68E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DD18183519D56B5B0053E68E /* Main.storyboard */; };
1513
DD18184319D56B5B0053E68E /* data.db in Resources */ = {isa = PBXBuildFile; fileRef = DD18183719D56B5B0053E68E /* data.db */; };
1614
DD18184419D56B5B0053E68E /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DD18183819D56B5B0053E68E /* Images.xcassets */; };
@@ -22,13 +20,13 @@
2220
DD18184E19D56BAF0053E68E /* SQLiteDB.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD18184C19D56BAF0053E68E /* SQLiteDB.swift */; };
2321
DD18184F19D56BAF0053E68E /* String-Extras.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD18184D19D56BAF0053E68E /* String-Extras.swift */; };
2422
DD18185119D56CDB0053E68E /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = DD18185019D56CDB0053E68E /* libsqlite3.dylib */; };
23+
DD7FFDBA1D23626C003EB06B /* Category.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD7FFDB81D23626C003EB06B /* Category.swift */; };
24+
DD7FFDBB1D23626C003EB06B /* Task.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD7FFDB91D23626C003EB06B /* Task.swift */; };
2525
/* End PBXBuildFile section */
2626

2727
/* Begin PBXFileReference section */
2828
DD04B4781BEC367E008E1261 /* SQLTable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SQLTable.swift; path = ../../SQLTable.swift; sourceTree = "<group>"; };
2929
DD04B4801BEC511B008E1261 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = "Base.lproj/Launch Screen.storyboard"; sourceTree = "<group>"; };
30-
DD04B4831BEC6D6D008E1261 /* Category.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Category.swift; sourceTree = "<group>"; };
31-
DD04B4841BEC6D6D008E1261 /* Task.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Task.swift; sourceTree = "<group>"; };
3230
DD18183619D56B5B0053E68E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
3331
DD18183719D56B5B0053E68E /* data.db */ = {isa = PBXFileReference; lastKnownFileType = file; path = data.db; sourceTree = "<group>"; };
3432
DD18183819D56B5B0053E68E /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
@@ -43,6 +41,8 @@
4341
DD18184D19D56BAF0053E68E /* String-Extras.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "String-Extras.swift"; path = "../../String-Extras.swift"; sourceTree = "<group>"; };
4442
DD18185019D56CDB0053E68E /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = usr/lib/libsqlite3.dylib; sourceTree = SDKROOT; };
4543
DD228C9319486E0400B74370 /* SQLiteDB-iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "SQLiteDB-iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
44+
DD7FFDB81D23626C003EB06B /* Category.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Category.swift; sourceTree = "<group>"; };
45+
DD7FFDB91D23626C003EB06B /* Task.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Task.swift; sourceTree = "<group>"; };
4646
/* End PBXFileReference section */
4747

4848
/* Begin PBXFrameworksBuildPhase section */
@@ -57,15 +57,6 @@
5757
/* End PBXFrameworksBuildPhase section */
5858

5959
/* Begin PBXGroup section */
60-
DD04B4821BEC6D6D008E1261 /* Shared */ = {
61-
isa = PBXGroup;
62-
children = (
63-
DD04B4831BEC6D6D008E1261 /* Category.swift */,
64-
DD04B4841BEC6D6D008E1261 /* Task.swift */,
65-
);
66-
path = Shared;
67-
sourceTree = "<group>";
68-
};
6960
DD04E1CF195C195B00494935 /* Third-party */ = {
7061
isa = PBXGroup;
7162
children = (
@@ -89,7 +80,6 @@
8980
DD18183B19D56B5B0053E68E /* Source */ = {
9081
isa = PBXGroup;
9182
children = (
92-
DD04B4821BEC6D6D008E1261 /* Shared */,
9383
DD18183C19D56B5B0053E68E /* AddCategoryViewController.swift */,
9484
DD18183D19D56B5B0053E68E /* AddTaskViewController.swift */,
9585
DD18183E19D56B5B0053E68E /* AppDelegate.swift */,
@@ -112,6 +102,7 @@
112102
isa = PBXGroup;
113103
children = (
114104
DD18183B19D56B5B0053E68E /* Source */,
105+
DD7FFDB71D23626C003EB06B /* Shared */,
115106
DD18183419D56B5B0053E68E /* Resources */,
116107
DD04E1CF195C195B00494935 /* Third-party */,
117108
DD18185219D56DBB0053E68E /* Frameworks */,
@@ -138,6 +129,16 @@
138129
path = "../../Frameworks/SQLiteDB-Swift";
139130
sourceTree = "<group>";
140131
};
132+
DD7FFDB71D23626C003EB06B /* Shared */ = {
133+
isa = PBXGroup;
134+
children = (
135+
DD7FFDB81D23626C003EB06B /* Category.swift */,
136+
DD7FFDB91D23626C003EB06B /* Task.swift */,
137+
);
138+
name = Shared;
139+
path = ../Shared;
140+
sourceTree = "<group>";
141+
};
141142
/* End PBXGroup section */
142143

143144
/* Begin PBXNativeTarget section */
@@ -219,11 +220,11 @@
219220
files = (
220221
DD18184919D56B5B0053E68E /* AppDelegate.swift in Sources */,
221222
DD04B4791BEC367E008E1261 /* SQLTable.swift in Sources */,
222-
DD04B4861BEC6D6D008E1261 /* Task.swift in Sources */,
223+
DD7FFDBB1D23626C003EB06B /* Task.swift in Sources */,
223224
DD18184B19D56B5B0053E68E /* TasksViewController.swift in Sources */,
224225
DD18184719D56B5B0053E68E /* AddCategoryViewController.swift in Sources */,
225226
DD18184E19D56BAF0053E68E /* SQLiteDB.swift in Sources */,
226-
DD04B4851BEC6D6D008E1261 /* Category.swift in Sources */,
227+
DD7FFDBA1D23626C003EB06B /* Category.swift in Sources */,
227228
DD18184A19D56B5B0053E68E /* CategoryViewController.swift in Sources */,
228229
DD18184F19D56BAF0053E68E /* String-Extras.swift in Sources */,
229230
DD18184819D56B5B0053E68E /* AddTaskViewController.swift in Sources */,

Examples/iOS/Source/AddCategoryViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class AddCategoryViewController: UITableViewController {
2424
// Save task
2525
let cat = Category()
2626
cat.name = txtCat.text!
27-
if cat.save().success {
27+
if cat.save() != 0 {
2828
let alert = UIAlertView(title:"SQLiteDB", message:"Category successfully saved!", delegate:nil, cancelButtonTitle: "OK")
2929
alert.show()
3030
}

Examples/iOS/Source/AddTaskViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class AddTaskViewController: UITableViewController {
2424
// Save task
2525
let task = Task()
2626
task.task = txtTask.text!
27-
if task.save().success {
27+
if task.save() != 0 {
2828
let alert = UIAlertView(title:"SQLiteDB", message:"Task successfully saved!", delegate:nil, cancelButtonTitle: "OK")
2929
alert.show()
3030
}

Examples/iOS/Source/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import UIKit
1212
class AppDelegate: UIResponder, UIApplicationDelegate {
1313

1414
var window: UIWindow?
15-
let db = SQLiteDB.sharedInstance()
15+
let db = SQLiteDB.sharedInstance
1616

1717
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
1818
return true

0 commit comments

Comments
 (0)