Start a new topic

popObjectForKey error

Hi all,

today I experienced this error all of a sudden, and can't run the app on device any more:

"Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString popObjectForKey:]: unrecognized selector sent to instance 0x15e51cb0'"

This messages repeats every time I launch app on my device.

Nowhere in my code I use popObjectForKey method so it must be something in Kinvey framework. Also found that another user had same problem, here :

He couldn't find the fix, eventually after couple of hours it started to work again.

Please find a fix for it.

Thank you

Hi Borna,

If you are still experiencing this issue, can you create a sample app that reproduces the issue and send it to

I was experiencing the same issue and just recently got it fixed. It appears to be caused by a corrupted KCSUser object in the keychain. Code snippet added on your SO post as well as below:

Insert this in your app delegate, prior to any call to [KCSUser activeUser]

NSArray *secItemClasses = @[(__bridge id)kSecClassGenericPassword,

(__bridge id)kSecClassInternetPassword,

(__bridge id)kSecClassCertificate,

(__bridge id)kSecClassKey,

(__bridge id)kSecClassIdentity];

for (id secItemClass in secItemClasses) {

NSDictionary *spec = @{(__bridge id)kSecClass: secItemClass};

SecItemDelete((__bridge CFDictionaryRef)spec);

I'm not so experienced to know what that code does, but it helped me. And now once again I can run my app on device. Thank you Nate.
The code Nate posted clears out the keychain (including the active user). Calling [KCSUser clearSavedCredentials] at the top of the program should do the same thing. Also kSecClassGenericPassword is sufficient since that is all that is stored by KinveyKit.
Now once again this error happened on my another device. How to stop this error for happening? What if this happens to user that bought the app from the store?

I really don't like this :(
Login or Signup to post a comment