BugFix: App crashes on iPhone 6S in case of rotation on login screen.

The crash reason was the following:
Terminating app due to uncaught exception 'NSRangeException', reason: 'Cannot remove an observer <RoomViewController> for the key path "isOffline" from <AppDelegate> because it is not registered as an observer.
This commit is contained in:
giomfo
2016-03-29 14:37:18 +02:00
parent f12196709b
commit f1b0917a87
+6 -6
View File
@@ -236,18 +236,12 @@
[super viewWillAppear:animated];
[self listenTypingNotifications];
// Observe network reachability
[[AppDelegate theDelegate] addObserver:self forKeyPath:@"isOffline" options:0 context:nil];
[self refreshActivitiesViewDisplay];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[[AppDelegate theDelegate] removeObserver:self forKeyPath:@"isOffline"];
// hide action
if (self.currentAlert)
{
@@ -286,6 +280,10 @@
[super viewDidAppear:animated];
// Observe network reachability
[[AppDelegate theDelegate] addObserver:self forKeyPath:@"isOffline" options:0 context:nil];
[self refreshActivitiesViewDisplay];
if (self.roomDataSource)
{
// Set visible room id
@@ -297,6 +295,8 @@
{
[super viewDidDisappear:animated];
[[AppDelegate theDelegate] removeObserver:self forKeyPath:@"isOffline"];
// Reset visible room id
[AppDelegate theDelegate].visibleRoomId = nil;
}