Showing
1 changed file
with
28 additions
and
5 deletions
... | @@ -196,10 +196,24 @@ didCompleteWithError:(NSError *)error | ... | @@ -196,10 +196,24 @@ didCompleteWithError:(NSError *)error |
196 | 196 | ||
197 | //Performance Improvement from #2672 | 197 | //Performance Improvement from #2672 |
198 | NSData *data = nil; | 198 | NSData *data = nil; |
199 | - if (self.mutableData) { | 199 | +// if (self.mutableData) { |
200 | - data = [self.mutableData copy]; | 200 | +// data = [self.mutableData copy]; |
201 | - //We no longer need the reference, so nil it out to gain back some memory. | 201 | +// //We no longer need the reference, so nil it out to gain back some memory. |
202 | - self.mutableData = nil; | 202 | +// self.mutableData = nil; |
203 | +// } | ||
204 | + | ||
205 | + @try { | ||
206 | + if (self.mutableData) { | ||
207 | + data = [self.mutableData copy]; | ||
208 | + //We no longer need the reference, so nil it out to gain back some memory. | ||
209 | + self.mutableData = nil; | ||
210 | + } | ||
211 | + } | ||
212 | + @catch (NSException *exception) { | ||
213 | + NSLog(@"delegate URLSession inner error: %@", exception.reason); | ||
214 | + } | ||
215 | + @finally { | ||
216 | +// NSLog(@"Finally condition"); | ||
203 | } | 217 | } |
204 | 218 | ||
205 | if (self.downloadFileURL) { | 219 | if (self.downloadFileURL) { |
... | @@ -1050,7 +1064,16 @@ didCompleteWithError:(NSError *)error | ... | @@ -1050,7 +1064,16 @@ didCompleteWithError:(NSError *)error |
1050 | 1064 | ||
1051 | // delegate may be nil when completing a task in the background | 1065 | // delegate may be nil when completing a task in the background |
1052 | if (delegate) { | 1066 | if (delegate) { |
1053 | - [delegate URLSession:session task:task didCompleteWithError:error]; | 1067 | +// [delegate URLSession:session task:task didCompleteWithError:error]; |
1068 | + @try { | ||
1069 | + [delegate URLSession:session task:task didCompleteWithError:error]; | ||
1070 | + } | ||
1071 | + @catch (NSException *exception) { | ||
1072 | + NSLog(@"delegate URLSession error: %@", exception.reason); | ||
1073 | + } | ||
1074 | + @finally { | ||
1075 | + // NSLog(@"Finally condition"); | ||
1076 | + } | ||
1054 | 1077 | ||
1055 | [self removeDelegateForTask:task]; | 1078 | [self removeDelegateForTask:task]; |
1056 | } | 1079 | } | ... | ... |
-
Please register or login to post a comment