Home Features Docs Blog Support GitHub

NSObject setvalueforKey error


(Van Van) #1

I’m about to log event to Firebase Analytic. My function like this:

    val objectTest : NSObject?
    objectTest = NSObject.alloc().init()
    objectTest.setValueForKey("sku123", "kFIRParameterItemID")

    val dictionaryParams: NSDictionary<String, NSObject>?
    dictionaryParams = NSMutableDictionary.alloc().init() as NSDictionary<String, NSObject>
    dictionaryParams["item1"] = objectTest

    FIRAnalytics.logEventWithNameParameters("name", dictionaryParams)

But this cause a crash error:
Terminating app due to uncaught exception ‘NSUnknownKeyException’, reason: '[<NSObject 0x60000001a430> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key kFIRParameterItemID.'

Greatly appreciated!