Manos Chorianopoulos

possible fix for AFURLSessionManager

...@@ -196,11 +196,25 @@ didCompleteWithError:(NSError *)error ...@@ -196,11 +196,25 @@ 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) {
200 +// data = [self.mutableData copy];
201 +// //We no longer need the reference, so nil it out to gain back some memory.
202 +// self.mutableData = nil;
203 +// }
204 +
205 + @try {
199 if (self.mutableData) { 206 if (self.mutableData) {
200 data = [self.mutableData copy]; 207 data = [self.mutableData copy];
201 //We no longer need the reference, so nil it out to gain back some memory. 208 //We no longer need the reference, so nil it out to gain back some memory.
202 self.mutableData = nil; 209 self.mutableData = nil;
203 } 210 }
211 + }
212 + @catch (NSException *exception) {
213 + NSLog(@"delegate URLSession inner error: %@", exception.reason);
214 + }
215 + @finally {
216 +// NSLog(@"Finally condition");
217 + }
204 218
205 if (self.downloadFileURL) { 219 if (self.downloadFileURL) {
206 userInfo[AFNetworkingTaskDidCompleteAssetPathKey] = self.downloadFileURL; 220 userInfo[AFNetworkingTaskDidCompleteAssetPathKey] = 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) {
1067 +// [delegate URLSession:session task:task didCompleteWithError:error];
1068 + @try {
1053 [delegate URLSession:session task:task didCompleteWithError:error]; 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 }
......