Skip to content

Commit 27b294f

Browse files
committed
Move to untyped Ids.
1 parent 0b4299a commit 27b294f

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

Example/NotesExample-iOS/NoteEditingViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ extension NoteEditingViewController: UIPickerViewDelegate {
186186

187187
func selectedPickerRow(for note: Note) -> Int {
188188
guard let authorId = note.author.targetId else { return 0 }
189-
guard let authorIndex = authors.firstIndex(where: { $0.id == authorId }) else { return 0 }
189+
guard let authorIndex = authors.firstIndex(where: { $0.id == authorId.value }) else { return 0 }
190190
return authorIndex + 1
191191
}
192192
}

Example/NotesExample-iOS/NotesOverviewViewController.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ class NotesOverviewViewController: UITableViewController {
1616
struct Filter {
1717
static var all: Filter { return Filter(authorId: nil) }
1818

19-
let authorId: EntityId<Author>?
19+
let authorId: Id?
2020
let query: Query<Note>
2121
var queryObserver: Observer?
2222

23-
init(authorId: EntityId<Author>?, noteBox: Box<Note> = Services.instance.noteBox) {
24-
self.authorId = authorId
23+
init(authorId: Id?, noteBox: Box<Note> = Services.instance.noteBox) {
24+
self.authorId = authorId?.value
2525

2626
if let authorId = authorId {
27-
query = try! noteBox.query { Note.author == authorId }.build()
27+
query = try! noteBox.query { Note.author.isEqual(to: authorId) }.build()
2828
} else {
2929
query = try! noteBox.query().build()
3030
}
@@ -35,7 +35,7 @@ class NotesOverviewViewController: UITableViewController {
3535
}
3636
}
3737

38-
func filterBy(authorId: EntityId<Author>?) {
38+
func filterBy(authorId: Id?) {
3939
filter = Filter(authorId: authorId)
4040
}
4141

@@ -100,7 +100,7 @@ extension NotesOverviewViewController {
100100
controller.mode = .draft
101101
controller.note = {
102102
let draft = Note()
103-
draft.author.targetId = filter.authorId
103+
draft.author.targetId = filter.authorId != nil ? EntityId<Author>(filter.authorId!) : nil
104104
draft.modificationDate = Date()
105105
return draft
106106
}()

Example/Shared/Author.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import ObjectBox
44

55
// objectbox:Entity
66
class Author {
7-
var id: EntityId<Author> // An `EntityId<Author>` is required by ObjectBox
7+
var id: Id // An ID is required by ObjectBox
88
var name: String
99
// objectbox: backlink = "author"
1010
var notes: ToMany<Note>

Example/Shared/Note.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import ObjectBox
44

55
class Note: Entity {
6-
var id: EntityId<Note> = 0 // An `EntityIdNote>` is required by ObjectBox
6+
var id: Id = 0 // An ID is required by ObjectBox
77
var title: String = "" {
88
didSet {
99
modificationDate = Date()

0 commit comments

Comments
 (0)