Fix reference cycle in example, remove unnecessary weak / strong (#4196)
* Fixed memory leak issues * Fixed memory leak issues * Fixed crash
This commit is contained in:
parent
4743faa83c
commit
0fba527112
@ -531,20 +531,17 @@ static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofi
|
||||
self.lock = [[NSLock alloc] init];
|
||||
self.lock.name = AFURLSessionManagerLockName;
|
||||
|
||||
__weak typeof(self) weakSelf = self;
|
||||
[self.session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) {
|
||||
|
||||
__strong typeof(weakSelf) strongSelf = weakSelf;
|
||||
for (NSURLSessionDataTask *task in dataTasks) {
|
||||
[strongSelf addDelegateForDataTask:task uploadProgress:nil downloadProgress:nil completionHandler:nil];
|
||||
[self addDelegateForDataTask:task uploadProgress:nil downloadProgress:nil completionHandler:nil];
|
||||
}
|
||||
|
||||
for (NSURLSessionUploadTask *uploadTask in uploadTasks) {
|
||||
[strongSelf addDelegateForUploadTask:uploadTask progress:nil completionHandler:nil];
|
||||
[self addDelegateForUploadTask:uploadTask progress:nil completionHandler:nil];
|
||||
}
|
||||
|
||||
for (NSURLSessionDownloadTask *downloadTask in downloadTasks) {
|
||||
[strongSelf addDelegateForDownloadTask:downloadTask progress:nil destination:nil completionHandler:nil];
|
||||
[self addDelegateForDownloadTask:downloadTask progress:nil destination:nil completionHandler:nil];
|
||||
}
|
||||
}];
|
||||
|
||||
|
||||
@ -50,7 +50,6 @@
|
||||
- (void)widgetPerformUpdateWithCompletionHandler:(void (^)(NCUpdateResult))completionHandler {
|
||||
[Post globalTimelinePostsWithBlock:^(NSArray *posts, NSError *error) {
|
||||
if (!error) {
|
||||
|
||||
self.post = posts.firstObject;
|
||||
[self savePost:self.post];
|
||||
|
||||
|
||||
@ -46,8 +46,10 @@
|
||||
self.postsArrayController.content = posts;
|
||||
}];
|
||||
|
||||
__weak __typeof(self)weakSelf = self;
|
||||
[[NSNotificationCenter defaultCenter] addObserverForName:kUserProfileImageDidLoadNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) {
|
||||
[self.tableView reloadData];
|
||||
__strong __typeof(weakSelf)strongSelf = weakSelf;
|
||||
[strongSelf.tableView reloadData];
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user