This is baffling me. I have hooked class methods on NSURLConnection
with no problems but I am stuck with +[NSURLSession sessionWithConfiguration:delegate:delegateQueue:]
.
I even tried logging all the class methods with class_copyMethodList (object_getClass([NSURLSession class]), &count);
and the class method is actually there:
sessionWithConfiguration:delegate:delegateQueue:
initialize
And the weird thing is the hook does get called so I think we got it right. Calling %orig()
and just passing the parameters down yields:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSURLSession sessionWithConfiguration:delegate:delegateQueue:]: unrecognized selector sent to class 0x1919932b8'
Here's the hook:
+ (NSURLSession *)sessionWithConfiguration:(NSURLSessionConfiguration *)configuration
delegate:(id<NSURLSessionDelegate>)delegate
delegateQueue:(NSOperationQueue *)queue
{
NSURLSession *origResult = %orig(configuration, delegate, queue);
return origResult;
}
Am I missing anything?
Setup details: rpetrich's Theos Mac OS X 10.9.5 iPad Air 1 iOS 7.1.2