From 3ccff22f87d7e10e13d60faefe35acee62be334f Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Fri, 2 May 2014 23:05:50 +0200 Subject: [PATCH] Fixed possible crash issue with deallocated delegate Fixed codestyle --- MacPass/MPOutlineViewController.m | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/MacPass/MPOutlineViewController.m b/MacPass/MPOutlineViewController.m index fb39a40c..60f5547a 100644 --- a/MacPass/MPOutlineViewController.m +++ b/MacPass/MPOutlineViewController.m @@ -66,21 +66,25 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell"; return self; } +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; + [self.outlineView setDelegate:nil]; +} - (void)didLoadView { - [_outlineView setDelegate:self]; - [_outlineView setMenu:[self _contextMenu]]; - [_outlineView setAllowsEmptySelection:YES]; - [_outlineView setFloatsGroupRows:NO]; - [_outlineView registerForDraggedTypes:@[ KPKGroupUTI, KPKEntryUTI ]]; - [_outlineView setDraggingSourceOperationMask:NSDragOperationEvery forLocal:YES]; - [_bottomBar setBorderType:HNHBorderTop|HNHBorderHighlight]; - [_addGroupButton setAction:[MPActionHelper actionOfType:MPActionAddGroup]]; + [self.outlineView setDelegate:self]; + [self.outlineView setMenu:[self _contextMenu]]; + [self.outlineView setAllowsEmptySelection:YES]; + [self.outlineView setFloatsGroupRows:NO]; + [self.outlineView registerForDraggedTypes:@[ KPKGroupUTI, KPKEntryUTI ]]; + [self.outlineView setDraggingSourceOperationMask:NSDragOperationEvery forLocal:YES]; + [self.bottomBar setBorderType:HNHBorderTop|HNHBorderHighlight]; + [self.addGroupButton setAction:[MPActionHelper actionOfType:MPActionAddGroup]]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didBecomeFirstResponder:) name:MPDidActivateViewNotification - object:_outlineView]; + object:self.outlineView]; }