tags:

views:

390

answers:

3

I have added an extension to NSData (base64 extension), which I kept over a separate infrastructure class lib project. But when i use this method from my main project i am getting an error like this: "-[NSConcreteData encodeBase64]: unrecognized selector sent to instance 0x121e60'".

But if i keep the same class in my main project itself, this will execute with out any issue.

I call this method in the following way: [dev setToken:[token encodeBase64]];

Please suggest why this is not working if i put the extension in another project. (I am already using some other extensions, eg. for NSDate, like this with out any issue.)

A: 

The issue is that the metadata necessary to configure a category is usually stripped by the linker because it appears to be dead. If you add the "-ObjC" LDFLAG to your project it will tell the linker to link all the potential ObjC info even if it appears to be dead.

Louis Gerbarg
I have already added -ObjC in 'Other Linked Flags'
Sreehari
In the flags for the app, or the library?
Louis Gerbarg
i have added on both app and lib.
Sreehari
+1  A: 

Is this on iPhone OS 3.0? The 3.0 SDK broke the use of -ObjC, but you usually are able to link in categories for a static library by adding the -all_load option to Other Linker Flags within your target application.

Brad Larson
A: 

Yes. It's 3.0. and i was able to link it successfully with -all_load option in Other Linker Flags. Thanks to all......!!

Sreehari