Search code examples
objective-ciosjsonjsonkit

JSONKit unrecognized selector while serializing


I am trying to use the JSONKit library and have included the source files in my project. I have included the JSONKit.h header so that the included category gives NSDictionary objects the JSONData and JSONString selectors.

  NSMutableDictionary* root = [NSMutableDictionary dictionary];
  [root setValue:@"CONNECT" forKey:@"command"];
  NSData* data = [root JSONData];

But at runtime I get the following error:

 -[__NSCFDictionary JSONString]: unrecognized selector sent to instance 0x784b870

Why is the category not adding the appropriate methods to NSDictionary objects?


Solution

  • I'm answering my own question because I just figured it out.

    My code is part of a static library that is being referenced from another iOS application. When including a static library that exports categories, the application that is using the category must be linked with the "-ObjC" linker flag.