1

Lastest Realm Swift 1.0.1 I do follow this composite primary key realm/swift

enter image description here

It's shows error following

enter image description here

How to i can write with Swift?

Community
  • 1
  • 1
Pan Park
  • 35
  • 1
  • 9

1 Answers1

0

You will need to drop the lazy specifier from the variable declaration as how the error messages states such properties are not supported. You don't want to ignore the property as you want to use it as a primary key.

Beside that I would recommend to separate your integer components within your compound key. (e.g. "\(id)|\(tourId)") Otherwise you can end up having different objects with the same conflicting primary key. e.g. You could have objects with compoundKey="123" for the combination id=1 tourId=23, but also for id=12 tourId=3.

marius
  • 7,766
  • 18
  • 30