Customkey / uniqueId?
neobie opened this issue · comments
Can someone guide me on how to use customkey or uniqueId? It gives error NSInvalidArgumentException
@IBAction func listMentionsButtonTapped(_ sender: UIButton) {
print("There are mention(s): \(String(describing: plugin?.mentions().count)) @% \(String(describing: plugin?.mentions()))")
var mentions = plugin?.mentions()
for mention in mentions as! [HKWMentionsAttribute]
{
mention.uniqueId() // this could error HakawaiDemoSwift[93047:40625502] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[HKWMentionsAttribute uniqueId]: unrecognized selector sent to instance 0x600003fa3ea0'
}
}
You're force casting mentions to be an array of HKWMentionsAttribute
when it may not actually be that. Please take that out and see if all the mentions
actually conform to that attribute. My guess is they don't.
As to how to use customkey or uniqueId, I'm not familiar. We'll take a look and get back to you.
This is a problem in our default implementation. Thanks for bringing it to our attention!
-
We don't provide a default implementation of
uniqueId
inHKWMentionsAttribute
, as we check for its existence in the state manager and default toentityId
if it doesn't exist. This means though that calling it directly onHKWMentionsAttribute
will crash. This isn't good. #109 fixes it. -
We also don't provide an implementation in
MentionEntity
in the demo app. If we did, then usingHKWMentionsAttributeProtocol
as the type for your array should have worked. We won't be changing this, as it should now properly have auniqueId
from the above change.
Thanks for raising this as an issue!