Skip to content

Commit 0059f43

Browse files
committed
Bluehawk trials
1 parent 9d1f8e1 commit 0059f43

File tree

4 files changed

+35
-8
lines changed

4 files changed

+35
-8
lines changed

tutorial/swift-ios/Task Tracker/Models.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ enum TaskStatus: String {
4848
}
4949

5050
// :code-block-start: task-model
51+
// :hide-start:
5152
class Task: Object {
52-
// :hide-start:
5353
@objc dynamic var _id: ObjectId = ObjectId.generate()
5454
@objc dynamic var _partition: String = ""
5555
@objc dynamic var name: String = ""
@@ -73,10 +73,14 @@ class Task: Object {
7373
self._partition = partition
7474
self.name = name
7575
}
76-
// :replace-with:
77-
// // TODO: Add Task model
78-
// :hide-end:
7976
}
77+
// :replace-with:
78+
// // TODO: Realm-ify Task model
79+
// class Task {
80+
// var name: String = ""
81+
// var statusEnum: TaskStatus = .Open
82+
// }
83+
// :hide-end:
8084
// :code-block-end:
8185

8286
struct Member {

tutorial/swift-ios/Task Tracker/ProjectsViewController.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,18 @@ class ProjectsViewController: UIViewController, UITableViewDelegate, UITableView
6565
navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Log Out", style: .plain, target: self, action: #selector(logOutButtonDidClick))
6666
}
6767

68+
// :code-block-start: number-of-rows-in-section
6869
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
70+
// :hide-start:
6971
// You always have at least one project (your own)
7072
return userData?.memberOf.count ?? 1
73+
// :replace-with:
74+
// // TODO: Each project should have its own row. Check the userData memberOf
75+
// // field for how many projects the user is a member of. However, the userData
76+
// // may not have loaded in yet. If that's the case, the user always has their
77+
// // own project, so you should always return at least 1.
78+
// return 0
79+
// :hide-end:
7180
}
7281

7382
// :code-block-start: cell-for-row-at

tutorial/swift-ios/Task Tracker/SceneDelegate.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ import RealmSwift
1212
// :code-block-start: initialize-app
1313
// :hide-start:
1414
let app = App(id: "tasktracker-qczfq")
15-
// :hide-end:
15+
// :replace-with:
1616
// // TODO: initialize the app with your Realm app ID
1717
// let app = App(id: "<your-realm-app-ID-here>")
18+
// :hide-end:
1819
// :code-block-end:
1920

2021
class SceneDelegate: UIResponder, UIWindowSceneDelegate {

tutorial/swift-ios/Task Tracker/TasksViewController.swift

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,19 @@ import RealmSwift
1111

1212
class TasksViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
1313

14+
// :code-block-start:
15+
let tableView = UITableView()
1416
let partitionValue: String
1517
let realm: Realm
16-
let tasks: Results<Task>
17-
let tableView = UITableView()
1818
var notificationToken: NotificationToken?
19-
19+
// :hide-start:
20+
let tasks: Results<Task>
21+
// :replace-with:
22+
// // TODO: Use Realm Results collection for `tasks`
23+
// let tasks: [Task] = []
24+
// :hide-end:
25+
// :code-block-end:
26+
2027
// :code-block-start: init
2128
required init(realm: Realm, title: String) {
2229

@@ -135,18 +142,24 @@ class TasksViewController: UIViewController, UITableViewDelegate, UITableViewDat
135142
return cell
136143
}
137144

145+
// :code-block-start: delete-task
138146
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
139147
guard editingStyle == .delete else { return }
140148

141149
// User can swipe to delete items.
142150
let task = tasks[indexPath.row]
143151

152+
// :hide-start:
144153
// All modifications to a realm must happen in a write block.
145154
try! realm.write {
146155
// Delete the Task.
147156
realm.delete(task)
148157
}
158+
// :replace-with:
159+
// // TODO: delete the task from the realm in a write block.
160+
// :hide-end:
149161
}
162+
// :code-block-end:
150163

151164
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
152165

0 commit comments

Comments
 (0)