user4992124
user4992124

Reputation: 1594

How to use RLMArray in Swift with Realm for Objective-C?

My app is mixed Objective-C and Swift, which forces me to use Realm for Objective-C. Now, I'm creating a new Realm model in Swift with an embedded RLMArray.

@objcMembers class KTPRestaurant: RLMObject {
    var name: String?
    dynamic public var tables: RLMArray<KTPTable>?
}

However, I keep getting an error saying that 'Property 'tables' is declared as 'id', which is not a supported RLMObject property type.. How should I declare the RLMArray?

Upvotes: 1

Views: 1026

Answers (1)

Anthony FSS
Anthony FSS

Reputation: 50

You should declare your RLMArray properties with the following syntax:

@objc dynamic var tables = RLMArray< KTPTable >(objectClassName:KTPTable.className())

Please refer to this RLMArray Properties from the Realm Docs. If you have face this issues : Terminating app due to uncaught exception 'RLMException'. Means You need to uninstall the app and reinstall the app to update the Realm.

Upvotes: 1

Related Questions