Reputation: 6470
I have realm object which is in objective-c class (our project is mix&match between swift and objective-c)
I know that I can access
[ClassName objectForPrimaryKey:]
in objc
but I don't know how can I use this method in swift file?
is this possible?
Thanks.
Upvotes: 1
Views: 1306
Reputation: 1409
In case if you are using Realm as an Objective-C library in Swift, then:
let object = ClassName(forPrimaryKey: primaryKey)
Upvotes: 1
Reputation: 759
In case of Swift you should use the following code:
let realm = try! Realm()
let object = realm.object(ofType: ClassName.self, forPrimaryKey: primaryKey)
Upvotes: 2