eonil
eonil

Reputation: 86015

How can I use category method on subclasses in Objective-C

Category methods added to specific class doesn't work at its subclass.

For me, I'm using JSONKit to manipulate JSON. JSONKit returns JKArray subclassing NSArray. And I have several methods added to NSArray. But when I execute my program, unrecognized selector sent to instance runtime exception thrown with the method.

How can I use the category method?

Upvotes: 1

Views: 359

Answers (1)

eonil
eonil

Reputation: 86015

I solved the problem by adding -ObjC flag to Other Linker Flags on build setting. Here's description. http://developer.apple.com/library/mac/#qa/qa1490/_index.html

My NSArray addition and JSONKit codes are in separated static library, and it was not linked well without the flag. Program is working well now. And also, the linker bug described the document looks fixed.

Upvotes: 4

Related Questions