Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User: Object {
- var company: Company? = Company()
- dynamic var password = ""
- dynamic var email = ""
- func persist() {
- let realm = try! Realm()
- try! realm.write {
- realm.add(self)
- }
- print(company)
- }
- }
- class Company: Object {
- dynamic var id = ""
- dynamic var name = ""
- }
- let user = User()
- user.email = "john@apple.com"
- user.password = "hey"
- user.company?.name = "apple"
- user.company?.id = "12"
- // here, if I check with debugger, all variable are properly filled
- user.persist()
- // here : company is = nil
- // it is nil at the 'print(company)
- // it is not nil before
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement