WIP: documentation and unit tests

This commit is contained in:
John Rommel Estropia
2016-03-12 20:13:38 +09:00
parent 8a1144b1be
commit 603dffffb0
21 changed files with 760 additions and 65 deletions

View File

@@ -99,12 +99,13 @@ class FetchingAndQueryingDemoViewController: UIViewController, UITableViewDataSo
// MARK: UITableViewDataSource
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
switch self.segmentedControl?.selectedSegmentIndex {
case .Some(Section.Fetching.rawValue):
case Section.Fetching.rawValue?:
return self.fetchingItems.count
case .Some(Section.Querying.rawValue):
case Section.Querying.rawValue?:
return self.queryingItems.count
default:
@@ -118,10 +119,10 @@ class FetchingAndQueryingDemoViewController: UIViewController, UITableViewDataSo
switch self.segmentedControl?.selectedSegmentIndex {
case .Some(Section.Fetching.rawValue):
case Section.Fetching.rawValue?:
cell.textLabel?.text = self.fetchingItems[indexPath.row].title
case .Some(Section.Querying.rawValue):
case Section.Querying.rawValue?:
cell.textLabel?.text = self.queryingItems[indexPath.row].title
default:
@@ -140,10 +141,10 @@ class FetchingAndQueryingDemoViewController: UIViewController, UITableViewDataSo
switch self.segmentedControl?.selectedSegmentIndex {
case .Some(Section.Fetching.rawValue):
case Section.Fetching.rawValue?:
self.performSegueWithIdentifier("FetchingResultsViewController", sender: indexPath)
case .Some(Section.Querying.rawValue):
case Section.Querying.rawValue?:
self.performSegueWithIdentifier("QueryingResultsViewController", sender: indexPath)
default:

View File

@@ -16,7 +16,7 @@ class QueryingResultsViewController: UITableViewController {
switch value {
case .Some(let array as [AnyObject]):
case (let array as [AnyObject])?:
self.values = array.map { (item: AnyObject) -> (title: String, detail: String) in
(
title: item.description,
@@ -24,7 +24,7 @@ class QueryingResultsViewController: UITableViewController {
)
}
case .Some(let item):
case let item?:
self.values = [
(
title: item.description,

View File

@@ -121,7 +121,7 @@ class ListObserverDemoViewController: UITableViewController, ListSectionObserver
switch (segue.identifier, segue.destinationViewController, sender) {
case (.Some("ObjectObserverDemoViewController"), let destinationViewController as ObjectObserverDemoViewController, let palette as Palette):
case ("ObjectObserverDemoViewController"?, let destinationViewController as ObjectObserverDemoViewController, let palette as Palette):
destinationViewController.palette = palette
default:

View File

@@ -74,16 +74,17 @@ class CustomLoggerViewController: UIViewController, CoreStoreLogger {
}
}
func assert(@autoclosure condition: () -> Bool, message: String, fileName: StaticString, lineNumber: Int, functionName: StaticString) {
func assert(@autoclosure condition: () -> Bool, @autoclosure message: () -> String, fileName: StaticString, lineNumber: Int, functionName: StaticString) {
if condition() {
return
}
let messageString = message()
GCDQueue.Main.async { [weak self] in
self?.textView?.insertText("\((fileName.stringValue as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ [Assert] \(message)\n\n")
self?.textView?.insertText("\((fileName.stringValue as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ [Assert] \(messageString)\n\n")
}
}
@@ -102,13 +103,13 @@ class CustomLoggerViewController: UIViewController, CoreStoreLogger {
switch self.segmentedControl?.selectedSegmentIndex {
case .Some(0):
case 0?:
self.dataStack.beginAsynchronous { (transaction) -> Void in
transaction.create(Into(Palette))
}
case .Some(1):
case 1?:
_ = try? dataStack.addStorageAndWait(
SQLiteStore(
fileName: "emptyStore.sqlite",
@@ -116,7 +117,7 @@ class CustomLoggerViewController: UIViewController, CoreStoreLogger {
)
)
case .Some(2):
case 2?:
self.dataStack.beginAsynchronous { (transaction) -> Void in
transaction.commit()