File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
iOS_SDK/OneSignalSDK/Source Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -75,9 +75,23 @@ @implementation DirectDownloadDelegate
7575@synthesize error, response, done;
7676
7777-(void )URLSession : (NSURLSession *)session dataTask : (NSURLSessionDataTask *)dataTask didReceiveData : (NSData *)data {
78- NSError *fileHandleError;
78+ NSError * __autoreleasing fileHandleError;
79+ NSError * __autoreleasing *fileHandleErrorPointer = &fileHandleError;
7980 if (@available (iOS 13.0 , *)) {
80- [outputHandle writeData: data error: &fileHandleError];
81+ // We need to use NSInvocation for reflection because performSelector cannot take pointer parameters
82+ SEL writeDataSelector = NSSelectorFromString (@" writeData:error:" );
83+ NSInvocation *invocation = [NSInvocation invocationWithMethodSignature: [NSFileHandle instanceMethodSignatureForSelector: writeDataSelector]];
84+ [invocation setTarget: outputHandle];
85+ [invocation setSelector: writeDataSelector];
86+ /*
87+ From Apple's Documentation on NSInvocation:
88+ Indices 0 and 1 indicate the hidden arguments self and _cmd, respectively;
89+ you should set these values directly with the target and selector properties.
90+ Use indices 2 and greater for the arguments normally passed in a message.
91+ */
92+ [invocation setArgument: &data atIndex: 2 ];
93+ [invocation setArgument: &fileHandleErrorPointer atIndex: 3 ];
94+ [invocation invoke ];
8195 } else {
8296 @try {
8397 [outputHandle writeData: data];
You can’t perform that action at this time.
0 commit comments