0

I have a project which has a category for NSString as below

@interface NSString (DataEncoding)

- (NSString *)com_EncryptWithISBN;

@end

@implementation NSString (DataEncoding)

- (NSString *)com_EncryptWithISBN
{
    return [self com_EncryptWithKey:[HMHBundleInfoAccess sharedInstance].ISBN];
}
@end

I have this in a different project(B) and it works fine within that project. Now I moved project B to another project A. Now the same code is giving me an error

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

I doubt whether the category is not linked properly when added as a subproject of Project A.

I have seen this link but no change. Do I need to add project B as a target dependency for Project A?

Any help highly appreciated.

Thanks

Community
  • 1
  • 1
Zach
  • 9,989
  • 19
  • 70
  • 107
  • just copy the code for the category to project a. if you are using cocoa pods, you can create a git repo for all the categories, and add the git repo to your cocoapods. That is a lot of work for just two projects. – John Jul 01 '14 at 14:13

1 Answers1

0

Add header NSString+DataEncoding.h (header of your category) to the files where you are using encrypting (where you are performing this selector).

skyylex
  • 855
  • 1
  • 10
  • 24
  • This is just wrong. If there wasn't a header it wouldn't compile. But he's getting an exception so it's a runtime error. – HAS Jul 11 '14 at 09:25
  • Not necessary. It's possible that calls were executed through performSelector:. – skyylex Jul 11 '14 at 09:28
  • 1
    If you use `-[performSelecor:]` you should also enable `-Wstrict-selector-match`! ;) See [this answer](http://programmers.stackexchange.com/a/124574) for more details. And then it would be a compile time error ;) – HAS Jul 11 '14 at 09:38
  • 1
    I didn't know about this. If this flag is enabled my answer is useless. Agree with you. – skyylex Jul 11 '14 at 09:51