Update GRDBDemo iOS/watchOS for Xcode 8 GM

This commit is contained in:
Gwendal Roué committed 2016-09-08 09:06:44 +02:00
1 parent a8b067885f
commit 7960528464
9 files changed
+79 -35

No files matched your search

@@ -9,8 +9,8 @@ func setupDatabase() {
// Connect to the database
// See https://github.com/groue/GRDB.swift/#database-connections
let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first! as NSString
let databasePath = documentsPath.stringByAppendingPathComponent("db.sqlite")
let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first! as NSString
let databasePath = documentsPath.appendingPathComponent("db.sqlite")
dbQueue = try! DatabaseQueue(path: databasePath)
@@ -23,8 +23,8 @@ func setupDatabase() {
// Compare person names in a localized case insensitive fashion
// See https://github.com/groue/GRDB.swift/#unicode
try db.create(table: "persons") { t in
t.column("id", .Integer).primaryKey()
t.column("name", .Text).notNull().collate(.localizedCaseInsensitiveCompare)
t.column("id", .integer).primaryKey()
t.column("name", .text).notNull().collate(.localizedCaseInsensitiveCompare)
}
}
@@ -5,16 +5,16 @@ class InterfaceController: WKInterfaceController {
@IBOutlet var table: WKInterfaceTable!
override func awakeWithContext(context: AnyObject?) {
super.awakeWithContext(context)
override func awake(withContext context: Any?) {
super.awake(withContext: context)
let persons = dbQueue.inDatabase { db in
Person.order(SQLColumn("name")).fetchAll(db)
Person.order(Column("name")).fetchAll(db)
}
table.setNumberOfRows(persons.count, withRowType: "Person")
for (i, person) in persons.enumerate() {
let row = table.rowControllerAtIndex(i) as! PersonRowController
for (i, person) in persons.enumerated() {
let row = table.rowController(at: i) as! PersonRowController
row.nameLabel.setText(person.name)
}
}
@@ -11,14 +11,14 @@ class Person: Record {
// MARK: Record overrides
override class func databaseTableName() -> String {
override class var databaseTableName: String {
return "persons"
}
required init(_ row: Row) {
required init(row: Row) {
id = row.value(named: "id")
name = row.value(named: "name")
super.init(row)
super.init(row: row)
}
override var persistentDictionary: [String : DatabaseValueConvertible?] {
@@ -27,7 +27,7 @@ class Person: Record {
"name": name]
}
override func didInsertWithRowID(rowID: Int64, forColumn column: String?) {
override func didInsert(with rowID: Int64, for column: String?) {
id = rowID
}
@@ -38,5 +38,4 @@ class Person: Record {
class func randomName() -> String {
return names[Int(arc4random_uniform(UInt32(names.count)))]
}
}
@@ -28,6 +28,8 @@
568C7AE41CA6CEBE00796484 /* PersonEditionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 568C7AE31CA6CEBE00796484 /* PersonEditionViewController.swift */; };
568C7AE61CA6F95300796484 /* DemoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 568C7AE51CA6F95300796484 /* DemoViewController.swift */; };
568C7AE81CA6FB6600796484 /* SimplePersonsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 568C7AE71CA6FB6600796484 /* SimplePersonsViewController.swift */; };
56F5ABD41D8142B8001F60CB /* GRDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5624A6EB1D80B13400AD3DCE /* GRDB.framework */; };
56F5ABD51D8142B8001F60CB /* GRDB.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 5624A6EB1D80B13400AD3DCE /* GRDB.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -171,6 +173,20 @@
remoteGlobalIDString = 56E5D7C91B4D3FED00430942;
remoteInfo = GRDBiOS;
};
56F5ABD21D8142A4001F60CB /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 568C7AC51CA6C6BF00796484 /* GRDB.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 5654909F1D5A4798005622CB;
remoteInfo = GRDBWatchOS;
};
56F5ABD61D8142B8001F60CB /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 568C7AC51CA6C6BF00796484 /* GRDB.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 5654909F1D5A4798005622CB;
remoteInfo = GRDBWatchOS;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
@@ -207,6 +223,17 @@
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
56F5ABD81D8142B9001F60CB /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
56F5ABD51D8142B8001F60CB /* GRDB.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
@@ -241,6 +268,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
56F5ABD41D8142B8001F60CB /* GRDB.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -376,10 +404,13 @@
5624A6AE1D80B13300AD3DCE /* Sources */,
5624A6AF1D80B13300AD3DCE /* Frameworks */,
5624A6B01D80B13300AD3DCE /* Resources */,
56F5ABD81D8142B9001F60CB /* Embed Frameworks */,
);
buildRules = (
);
dependencies = (
56F5ABD31D8142A4001F60CB /* PBXTargetDependency */,
56F5ABD71D8142B8001F60CB /* PBXTargetDependency */,
);
name = "GRDBDemoWatchOS Extension";
productName = "GRDBDemoWatchOS Extension";
@@ -653,6 +684,16 @@
name = GRDBiOS;
targetProxy = 568C7ADC1CA6C6D100796484 /* PBXContainerItemProxy */;
};
56F5ABD31D8142A4001F60CB /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = GRDBWatchOS;
targetProxy = 56F5ABD21D8142A4001F60CB /* PBXContainerItemProxy */;
};
56F5ABD71D8142B8001F60CB /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = GRDBWatchOS;
targetProxy = 56F5ABD61D8142B8001F60CB /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
@@ -791,6 +832,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
@@ -831,6 +873,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
VALIDATE_PRODUCT = YES;
};
name = Release;
@@ -848,7 +891,6 @@
PRODUCT_BUNDLE_IDENTIFIER = GRDB.GRDBDemoiOS;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
@@ -866,7 +908,6 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
};
name = Release;
};
@@ -4,7 +4,7 @@ import UIKit
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]? = [:]) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
setupDatabase(application)
return true
}
@@ -10,12 +10,12 @@ class PersonEditionViewController: UITableViewController {
var cancelButtonHidden: Bool = false { didSet { configureView() } }
var commitButtonHidden: Bool = false { didSet { configureView() } }
@IBOutlet private weak var cancelBarButtonItem: UIBarButtonItem!
@IBOutlet private weak var commitBarButtonItem: UIBarButtonItem!
@IBOutlet private weak var nameCell: UITableViewCell!
@IBOutlet private weak var nameTextField: UITextField!
@IBOutlet private weak var scoreCell: UITableViewCell!
@IBOutlet private weak var scoreTextField: UITextField!
@IBOutlet fileprivate weak var cancelBarButtonItem: UIBarButtonItem!
@IBOutlet fileprivate weak var commitBarButtonItem: UIBarButtonItem!
@IBOutlet fileprivate weak var nameCell: UITableViewCell!
@IBOutlet fileprivate weak var nameTextField: UITextField!
@IBOutlet fileprivate weak var scoreCell: UITableViewCell!
@IBOutlet fileprivate weak var scoreTextField: UITextField!
func applyChanges() {
if let name = nameTextField.text, !name.isEmpty {
@@ -58,7 +58,7 @@ class PersonEditionViewController: UITableViewController {
extension PersonEditionViewController {
override func shouldPerformSegue(withIdentifier identifier: String, sender: AnyObject?) -> Bool {
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
// Force keyboard to dismiss early
view.endEditing(true)
return true
@@ -63,7 +63,7 @@ class PersonsViewController: UITableViewController {
extension PersonsViewController : PersonEditionViewControllerDelegate {
override func prepare(for segue: UIStoryboardSegue, sender: AnyObject?) {
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "EditPerson" {
let person = personsController.record(at: tableView.indexPathForSelectedRow!)
let controller = segue.destination as! PersonEditionViewController
@@ -152,7 +152,7 @@ extension PersonsViewController {
extension PersonsViewController {
private func configureToolbar() {
fileprivate func configureToolbar() {
toolbarItems = [
UIBarButtonItem(title: "Name ⬆︎", style: .plain, target: self, action: .sortByName),
UIBarButtonItem(title: "Score ⬇︎", style: .plain, target: self, action: .sortByScore),
@@ -31,7 +31,7 @@ class SimplePersonsViewController: UITableViewController {
extension SimplePersonsViewController : PersonEditionViewControllerDelegate {
override func prepare(for segue: UIStoryboardSegue, sender: AnyObject?) {
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "EditPerson" {
let person = persons[tableView.indexPathForSelectedRow!.row]
let controller = segue.destination as! PersonEditionViewController
+12 -8
View File
@@ -919,6 +919,11 @@
56F0B9921B6001C600A2F135 /* NSDateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56F0B98E1B6001C600A2F135 /* NSDateTests.swift */; };
56F26C1C1CEE3F32007969C4 /* AdapterRowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565F03C11CE5D3AA00DE108F /* AdapterRowTests.swift */; };
56F26C241CEE3F34007969C4 /* AdapterRowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565F03C11CE5D3AA00DE108F /* AdapterRowTests.swift */; };
56F5ABD91D814330001F60CB /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5690C33F1D23E82A00E59934 /* Data.swift */; };
56F5ABDA1D814330001F60CB /* NSData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5657AAB81D107001006283EF /* NSData.swift */; };
56F5ABDB1D814330001F60CB /* NSDate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5657AAA91D106E39006283EF /* NSDate.swift */; };
56F5ABDC1D814330001F60CB /* URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5657AB0E1D10899D006283EF /* URL.swift */; };
56F5ABDD1D814330001F60CB /* UUID.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A8C22F1D1914540096E9D4 /* UUID.swift */; };
56FC78661BBAEB8C00CA1285 /* MappingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FC78641BBAEB8C00CA1285 /* MappingTests.swift */; };
56FC78671BBAEB8C00CA1285 /* MappingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FC78641BBAEB8C00CA1285 /* MappingTests.swift */; };
56FC78681BBAEB8C00CA1285 /* ManagedDataControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FC78651BBAEB8C00CA1285 /* ManagedDataControllerTests.swift */; };
@@ -3394,6 +3399,7 @@
565490CF1D5AE252005622CB /* NSNumber.swift in Sources */,
565490E21D5AE252005622CB /* Record.swift in Sources */,
565490C11D5AE236005622CB /* FetchRequest.swift in Sources */,
56F5ABDA1D814330001F60CB /* NSData.swift in Sources */,
565490BD1D5AE236005622CB /* DatabaseStore.swift in Sources */,
565490B91D5AE236005622CB /* DatabasePool.swift in Sources */,
565490D81D5AE252005622CB /* DatabaseMigrator.swift in Sources */,
@@ -3402,6 +3408,7 @@
565490D91D5AE252005622CB /* Migration.swift in Sources */,
565490D51D5AE252005622CB /* RawRepresentable.swift in Sources */,
565490C51D5AE236005622CB /* SerializedDatabase.swift in Sources */,
56F5ABDB1D814330001F60CB /* NSDate.swift in Sources */,
565490D71D5AE252005622CB /* Utils.swift in Sources */,
565490BF1D5AE236005622CB /* DatabaseValueConvertible.swift in Sources */,
565490BB1D5AE236005622CB /* DatabaseReader.swift in Sources */,
@@ -3420,6 +3427,7 @@
565490CC1D5AE252005622CB /* (null) in Sources */,
565490DB1D5AE252005622CB /* SQLCollation.swift in Sources */,
565490C61D5AE236005622CB /* Statement.swift in Sources */,
56F5ABD91D814330001F60CB /* Data.swift in Sources */,
565490D41D5AE252005622CB /* (null) in Sources */,
565490B61D5AE236005622CB /* Configuration.swift in Sources */,
565490E11D5AE252005622CB /* Persistable.swift in Sources */,
@@ -3427,8 +3435,10 @@
565490C81D5AE252005622CB /* CGFloat.swift in Sources */,
565490D21D5AE252005622CB /* NSUUID.swift in Sources */,
565490DC1D5AE252005622CB /* SQLFunction.swift in Sources */,
56F5ABDC1D814330001F60CB /* URL.swift in Sources */,
565490D31D5AE252005622CB /* (null) in Sources */,
565490DE1D5AE252005622CB /* SQLSelectQuery.swift in Sources */,
56F5ABDD1D814330001F60CB /* UUID.swift in Sources */,
565490CB1D5AE252005622CB /* (null) in Sources */,
565490D61D5AE252005622CB /* StandardLibrary.swift in Sources */,
565490B81D5AE236005622CB /* DatabaseError.swift in Sources */,
@@ -4864,7 +4874,6 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
@@ -4888,7 +4897,6 @@
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
@@ -5002,6 +5010,7 @@
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
@@ -5039,6 +5048,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MTL_ENABLE_DEBUG_INFO = NO;
SWIFT_VERSION = 3.0;
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
@@ -5061,7 +5071,6 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
@@ -5082,7 +5091,6 @@
MACOSX_DEPLOYMENT_TARGET = 10.9;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
};
name = Release;
};
@@ -5104,7 +5112,6 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
@@ -5129,7 +5136,6 @@
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
@@ -5189,7 +5195,6 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
@@ -5211,7 +5216,6 @@
MACOSX_DEPLOYMENT_TARGET = 10.9;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
};
name = Release;
};