title: Quickblox: I am receiving EXC_BAD_ACCESS(code=1, address"mem-address") when joining/leaving chat rooms
body: <p>Hey so the title gives some information, but let me expand further. In my iOS application, I am receiving this EXC_BAD_ACCESS message when I am joining and leaving chat rooms quickly (by selecting a thread in a UITableView and view is getting pushed to a new UIViewController and then popping back to the UITableViewController). I am trying to fix this problem because it is more prevalent with slower network connections, and I want to avoid crashes. I use the Quickblox Chat service based on the ChatService.h/.m files that are in the sample-chat xcode project. Here is the only modified code:</p>
  
  <pre><code>- (void)chatRoomDidEnter:(QBChatRoom *)room{
      if (self.joinRoomCompletionBlock) {
          self.joinRoomCompletionBlock(room);
          self.joinRoomCompletionBlock = nil;
      }
  
      [[NSNotificationCenter defaultCenter] postNotificationName:@"kNotificationChatRoomDidEnter"
                                                      object:nil userInfo:nil];
  }
  </code></pre>
  
  <p>The crash happens at the end of this method and when I turned on NSZombies, I got this error message:</p>
  
  <pre><code>*** -[QBChatRoom retain]: message sent to deallocated instance 0x15e6bbe0
  </code></pre>
  
  <p>I am actually calling these methods from that ChatService in my UIViewController's viewWillAppear/Disappear methods (written in Swift):</p>
  
  <pre><code>override func viewWillAppear(animated: Bool) {
      super.viewWillAppear(animated)
      self.chatRoom = self.dialog.chatRoom
      ChatService.instance().joinRoom(self.chatRoom, completionBlock: { (joinedChatRoom : QBChatRoom!) -&gt; Void in
          //joined
      })
  }
  
  override func viewWillDisappear(animated: Bool)  {
      super.viewWillDisappear(animated)
  
      let notificationCenter = NSNotificationCenter.defaultCenter()
      notificationCenter.removeObserver(self);
  
      if (self.chatRoom != nil) {
          ChatService.instance().leaveRoom(self.chatRoom);
          self.chatRoom = nil
      }
  }
  </code></pre>
  
  <p>Thanks in advance for any insight with this issue.</p>