My goal is to develop this relationship with realm swift:
I have a dataset with all characters. Then I have a few lists, to which I want to add certain characters to.
This is what I got so far in swift code:
//
// Lists.swift
//
// Created by Guest on 28.01.19.
// Copyright © 2019 Dom. All rights reserved.
//
// https://academy.realm.io/posts/realm-primary-keys-tutorial/
import Foundation
import RealmSwift
class Lists: Object {
// making use of primary keys
@objc dynamic var listID = UUID().uuidString
@objc dynamic var listName : String = ""
@objc dynamic var listDesc : String = ""
@objc dynamic var listProgressPercentage : Int = 0
// lists all characters associated with this list
var charIDs = List<Characters>()
override static func primaryKey() -> String? {
return "listID"
}
}
And:
//
// Characters.swift
//
// Created by Guest on 28.01.19.
// Copyright © 2019 Dom. All rights reserved.
//
import Foundation
import RealmSwift
class Characters: Object {
// get charID from dictionary.txt later
@objc dynamic var charID = 0
@objc dynamic var character : String = ""
}
My question: - Lists is still empty. How do it now add a new list and add e.g. 25 different object references to the objects in "Characters"?
Appreciate your help!