I wanted to create a category on NSURLSession. The app compiles ok, but when I attempt to call the category methods I get
-[__NSCFURLSession doSomething]: unrecognized selector sent to instance 0xbf6b0f0
<unknown>:0: error: -[NSURLSession_UPnPTests testCategory] : -[__NSCFURLSession doSomething]: unrecognized selector sent to instance 0xbf6b0f0
Very strange, here is a test class I built to show the issue. The category on the NSString works fine, but the category on NSURLSession fails to find the method at runtime. I suspect this is something internal.
Opinions please :-)
#import <XCTest/XCTest.h>
@interface NSString (test)
-(void) doSomethingHere;
@end
@implementation NSString (test)
-(void) doSomethingHere {
NSLog(@"Hello string");
}
@end
@interface NSURLSession (test)
-(void) doSomething;
@end
@implementation NSURLSession (test)
-(void) doSomething {
NSLog(@"Hello!!!!");
}
@end
@interface NSURLSession_UPnPTests : XCTestCase
@end
@implementation NSURLSession_UPnPTests
-(void) testCategory {
[@"abc" doSomethingHere];
NSURLSession *session = [NSURLSession sharedSession];
[session doSomething];
}
@end