Dominik Sturm
Dominik Sturm

Reputation: 55

Error using LinkingObjects(fromType:property:) - Use of unresolved identifier 'LinkingObjects'

Following the Realm Swift documentation i declared some classes Car and Tour like this:

import RealmSwift


class Car: Object {
   dynamic var id = ""
   let tours = List<Tour>()
}

class Tour: Object {
   dynamic var id = "" 
   let cars = LinkingObjects(fromType: Car.self, property: "tours")
}

When I try to build this, i get an error: Use of unresolved identifier 'LinkingObjects'. I tried to clean Xcode's Derived Data like this post says, but the build still fails.

Does anyone know, how to resolve this error?

Upvotes: 0

Views: 269

Answers (1)

Dominik Sturm
Dominik Sturm

Reputation: 55

Ok, I resolved the error by using

 var cars : Car? {
     return linkingObjects(Car.self, forProperty: "tours").first
 }

for a to-one-relationship. It seems that i've installed an older version of Realm (0.97.0) and checked the wrong documentation. 😅

Upvotes: 1

Related Questions