set UiContactCell contact to null when leaving the view to avoid memory leak

This commit is contained in:
Benjamin Reis 2016-11-21 12:10:42 +01:00
parent 333a9eed63
commit f27f1de1ee
4 changed files with 12 additions and 0 deletions

View file

@ -30,5 +30,6 @@
}
- (void)loadData;
- (void)loadSearchedData;
- (void)removeAllContacts;
@end

View file

@ -67,6 +67,15 @@
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
[self removeAllContacts];
}
- (void)removeAllContacts {
for (NSInteger j = 0; j < [self.tableView numberOfSections]; ++j) {
for (NSInteger i = 0; i < [self.tableView numberOfRowsInSection:j]; ++i) {
[[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:j]] setContact:nil];
}
}
}
#pragma mark -

View file

@ -150,6 +150,7 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void) viewWillDisappear:(BOOL)animated {
self.view = NULL;
[self.tableController removeAllContacts];
}
#pragma mark -

View file

@ -53,6 +53,7 @@
}
- (void)dealloc {
self.contact = NULL;
[NSNotificationCenter.defaultCenter removeObserver:self];
}