Use weak refs to keep track of sessions. Otherwise it was impossible to deallocate them.
authorEdouard Tisserant <edouard@pep-project.org>
Wed, 17 May 2017 17:57:53 +0200
changeset 191c0872370f8fa
parent 190 68a3191cde14
child 192 9e94360802b5
Use weak refs to keep track of sessions. Otherwise it was impossible to deallocate them.
pEpObjCAdapter/PEPObjCAdapter.m
     1.1 --- a/pEpObjCAdapter/PEPObjCAdapter.m	Wed May 17 13:10:19 2017 +0200
     1.2 +++ b/pEpObjCAdapter/PEPObjCAdapter.m	Wed May 17 17:57:53 2017 +0200
     1.3 @@ -1,6 +1,6 @@
     1.4  //
     1.5 -//  pEpiOSAdapter.m
     1.6 -//  pEpiOSAdapter
     1.7 +//  pEpObjCAdapter.m
     1.8 +//  pEpObjCAdapter
     1.9  //
    1.10  //  Created by Volker Birk on 28.04.15.
    1.11  //  Copyright (c) 2015 p≡p. All rights reserved.
    1.12 @@ -348,9 +348,11 @@
    1.13      }
    1.14  
    1.15      NSMutableArray* sessionList = [PEPObjCAdapter boundSessions];
    1.16 +    NSValue* v;
    1.17      PEPSession* session;
    1.18      @synchronized (sessionList) {
    1.19 -        for (session in sessionList) {
    1.20 +        for (v in sessionList) {
    1.21 +            session = [v nonretainedObjectValue];
    1.22              [PEPObjCAdapter attachSyncSession:[session session]];
    1.23          }
    1.24      }
    1.25 @@ -359,9 +361,11 @@
    1.26  + (void)stopSync
    1.27  {
    1.28      NSMutableArray* sessionList = [PEPObjCAdapter boundSessions];
    1.29 +    NSValue* v;
    1.30      PEPSession* session;
    1.31      @synchronized (sessionList) {
    1.32 -        for (session in sessionList) {
    1.33 +        for (v in sessionList) {
    1.34 +            session = [v nonretainedObjectValue];
    1.35              [PEPObjCAdapter detachSyncSession:[session session]];
    1.36          }
    1.37      }
    1.38 @@ -397,7 +401,7 @@
    1.39  {
    1.40      NSMutableArray* sessionList = [PEPObjCAdapter boundSessions];
    1.41      @synchronized (sessionList) {
    1.42 -        [sessionList addObject:session];
    1.43 +        [sessionList addObject:[NSValue valueWithNonretainedObject:session]];
    1.44      }
    1.45  
    1.46      [PEPObjCAdapter registerExamineFunction:[session session]];
    1.47 @@ -410,7 +414,7 @@
    1.48      
    1.49      NSMutableArray* sessionList = [PEPObjCAdapter boundSessions];
    1.50      @synchronized (sessionList) {
    1.51 -        [sessionList removeObject:session];
    1.52 +        [sessionList removeObject:[NSValue valueWithNonretainedObject:session]];
    1.53      }
    1.54  
    1.55  }