Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

Commit

Permalink
Convert observers to block variables to avoid releasing
Browse files Browse the repository at this point in the history
  • Loading branch information
ismailgulek committed Jun 11, 2020
1 parent 84a2703 commit 44f3c67
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions MatrixKit/Models/Room/MXKRoomDataSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,7 @@ + (void)ensureSessionStateForDataSource:(MXKRoomDataSource*)roomDataSource initi
else
{
// wait for session state to be store data ready
id sessionStateObserver = nil;
sessionStateObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXSessionStateDidChangeNotification object:mxSession queue:nil usingBlock:^(NSNotification * _Nonnull note) {
__block id sessionStateObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXSessionStateDidChangeNotification object:mxSession queue:nil usingBlock:^(NSNotification * _Nonnull note) {
if (mxSession.state >= MXSessionStateStoreDataReady)
{
[[NSNotificationCenter defaultCenter] removeObserver:sessionStateObserver];
Expand Down Expand Up @@ -241,8 +240,7 @@ + (void)ensureInitialEventExistenceForDataSource:(MXKRoomDataSource*)roomDataSou
{
// give a chance for the specific event to be existent, for only one sync
// use kMXSessionDidSyncNotification here instead of MXSessionStateRunning, because session does not send this state update if it's already in this state
id syncObserver = nil;
syncObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXSessionDidSyncNotification object:mxSession queue:nil usingBlock:^(NSNotification * _Nonnull note) {
__block id syncObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXSessionDidSyncNotification object:mxSession queue:nil usingBlock:^(NSNotification * _Nonnull note) {
[[NSNotificationCenter defaultCenter] removeObserver:syncObserver];
[self finalizeRoomDataSource:roomDataSource onComplete:onComplete];
}];
Expand Down

0 comments on commit 44f3c67

Please sign in to comment.