Skip to content

Commit 5213373

Browse files
committed
ios 9+ will unregister nsnotifcation observers automatically on dealloc
1 parent 529cfb1 commit 5213373

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

Mage/ObservationTableViewController.m

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,27 +65,27 @@ - (void)viewDidLoad {
6565
[defaults addObserver:self
6666
forKeyPath:kObservationTimeFilterKey
6767
options:NSKeyValueObservingOptionNew
68-
context:NULL];
68+
context:nil];
6969

7070
[defaults addObserver:self
7171
forKeyPath:kObservationTimeFilterNumberKey
7272
options:NSKeyValueObservingOptionNew
73-
context:NULL];
73+
context:nil];
7474

7575
[defaults addObserver:self
7676
forKeyPath:kObservationTimeFilterUnitKey
7777
options:NSKeyValueObservingOptionNew
78-
context:NULL];
78+
context:nil];
7979

8080
[defaults addObserver:self
8181
forKeyPath:kImportantFilterKey
8282
options:NSKeyValueObservingOptionNew
83-
context:NULL];
83+
context:nil];
8484

8585
[defaults addObserver:self
8686
forKeyPath:kFavortiesFilterKey
8787
options:NSKeyValueObservingOptionNew
88-
context:NULL];
88+
context:nil];
8989

9090
self.childCoordinators = [[NSMutableArray alloc] init];
9191
self.refreshControl = [[UIRefreshControl alloc] init];
@@ -127,13 +127,6 @@ - (void) viewWillDisappear:(BOOL)animated {
127127
}
128128

129129
- (void) dealloc {
130-
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
131-
[defaults removeObserver:self forKeyPath:kObservationTimeFilterKey];
132-
[defaults removeObserver:self forKeyPath:kObservationTimeFilterUnitKey];
133-
[defaults removeObserver:self forKeyPath:kObservationTimeFilterNumberKey];
134-
[defaults removeObserver:self forKeyPath:kImportantFilterKey];
135-
[defaults removeObserver:self forKeyPath:kFavortiesFilterKey];
136-
137130
self.observationDataStore.observations.delegate = nil;
138131
}
139132

0 commit comments

Comments
 (0)